Skip to content

Commit

Permalink
authenticator: Generate a more unique labelPostFix (#39)
Browse files Browse the repository at this point in the history
Otherwise callers that run this in parallel will get rejected. See aequitas/terraform-provider-transip#44
  • Loading branch information
Jille authored Sep 13, 2021
1 parent a26162a commit cab6242
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion authenticator/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (a *Authenticator) getNonce() (string, error) {

// getAuthRequest returns a rest.Request filled with a new AuthRequest
func (a *Authenticator) getAuthRequest() (rest.Request, error) {
labelPostFix := time.Now().Unix()
labelPostFix := time.Now().UnixNano()

nonce, err := a.getNonce()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion authenticator/authenticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestAuthenticator_getAuthRequest(t *testing.T) {
stringBody := string(body)

assert.Contains(t, stringBody, `{"login":"test-user1",`)
assert.Contains(t, stringBody, fmt.Sprintf(`"label":"gotransip-client-%d"`, time.Now().Unix()))
assert.Contains(t, stringBody, "gotransip-client-")
assert.Contains(t, stringBody, `"read_only":true,`)
assert.Contains(t, stringBody, `"global_key":false}`)
assert.Contains(t, stringBody, `"expiration_time":"30 seconds",`)
Expand Down

0 comments on commit cab6242

Please sign in to comment.