Skip to content

Commit

Permalink
Annotate client.CSAPI with .Password (#705)
Browse files Browse the repository at this point in the history
* Annotate `client.CSAPI` with `.Password`

This field isn't really used anywhere, but it is extremely
useful to be tagged with the client itself when you want to
derive a new client from an existing one. Mostly helpful for
Complement Crypto currently.

* Review comments
  • Loading branch information
kegsay authored Jan 26, 2024
1 parent f24331b commit 458bfba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type CSAPI struct {
UserID string
AccessToken string
DeviceID string
Password string // if provided
BaseURL string
Client *http.Client
// how long are we willing to wait for MustSyncUntil.... calls
Expand Down
6 changes: 6 additions & 0 deletions internal/docker/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (d *Deployment) Register(t ct.TestLike, hsName string, opts helpers.Registr
Client: client.NewLoggedClient(t, hsName, nil),
SyncUntilTimeout: 5 * time.Second,
Debug: d.Deployer.debugLogging,
Password: opts.Password,
}
// Appending a slice is not thread-safe. Protect the write with a mutex.
dep.CSAPIClientsMutex.Lock()
Expand All @@ -107,6 +108,7 @@ func (d *Deployment) Register(t ct.TestLike, hsName string, opts helpers.Registr
password := opts.Password
if password == "" {
password = "complement_meets_min_password_req"
client.Password = password
}

localpart := fmt.Sprintf("user-%v", d.localpartCounter.Add(1))
Expand Down Expand Up @@ -147,6 +149,10 @@ func (d *Deployment) Login(t ct.TestLike, hsName string, existing *client.CSAPI,
Client: client.NewLoggedClient(t, hsName, nil),
SyncUntilTimeout: 5 * time.Second,
Debug: d.Deployer.debugLogging,
Password: existing.Password,
}
if opts.Password != "" {
c.Password = opts.Password
}
// Appending a slice is not thread-safe. Protect the write with a mutex.
dep.CSAPIClientsMutex.Lock()
Expand Down

0 comments on commit 458bfba

Please sign in to comment.