Skip to content

Commit 25a2d5c

Browse files
authored
Add DeviceID to login opts (#693)
Co-authored-by: Kegan Dougal <=>
1 parent f8f2b2a commit 25a2d5c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

helpers/clientopts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ type RegistrationOpts struct {
99

1010
type LoginOpts struct {
1111
Password string // default 'complement_meets_min_password_requirement'
12+
DeviceID string // default '' (generate new)
1213
}

internal/docker/deployment.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,27 @@ func (d *Deployment) Login(t *testing.T, hsName string, existing *client.CSAPI,
142142
if err != nil {
143143
t.Fatalf("Deployment.Login: existing CSAPI client has invalid user ID '%s', cannot login as this user: %s", existing.UserID, err)
144144
}
145-
client := &client.CSAPI{
145+
c := &client.CSAPI{
146146
BaseURL: dep.BaseURL,
147147
Client: client.NewLoggedClient(t, hsName, nil),
148148
SyncUntilTimeout: 5 * time.Second,
149149
Debug: d.Deployer.debugLogging,
150150
}
151151
// Appending a slice is not thread-safe. Protect the write with a mutex.
152152
dep.CSAPIClientsMutex.Lock()
153-
dep.CSAPIClients = append(dep.CSAPIClients, client)
153+
dep.CSAPIClients = append(dep.CSAPIClients, c)
154154
dep.CSAPIClientsMutex.Unlock()
155-
userID, accessToken, deviceID := client.LoginUser(t, localpart, opts.Password)
155+
var userID, accessToken, deviceID string
156+
if opts.DeviceID == "" {
157+
userID, accessToken, deviceID = c.LoginUser(t, localpart, opts.Password)
158+
} else {
159+
userID, accessToken, deviceID = c.LoginUser(t, localpart, opts.Password, client.WithDeviceID(opts.DeviceID))
160+
}
156161

157-
client.UserID = userID
158-
client.AccessToken = accessToken
159-
client.DeviceID = deviceID
160-
return client
162+
c.UserID = userID
163+
c.AccessToken = accessToken
164+
c.DeviceID = deviceID
165+
return c
161166
}
162167

163168
func (d *Deployment) Network() string {

0 commit comments

Comments
 (0)