fix(tests): add orgID to Validate unpack — Validate returns 4 values (#1366)
This commit is contained in:
parent
00bd73f8c8
commit
8dde18bc61
@ -74,12 +74,12 @@ func TestValidate_HappyPath(t *testing.T) {
|
||||
|
||||
mock.ExpectQuery(`SELECT id, prefix FROM org_api_tokens`).
|
||||
WithArgs(hash[:]).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "prefix"}).AddRow("tok-live", "abcd1234"))
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "prefix"}).AddRow("tok-live", "abcd1234", nil))
|
||||
mock.ExpectExec(`UPDATE org_api_tokens SET last_used_at`).
|
||||
WithArgs("tok-live").
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
|
||||
id, prefix, err := Validate(context.Background(), db, plaintext)
|
||||
id, prefix, orgID, err := Validate(context.Background(), db, plaintext)
|
||||
if err != nil {
|
||||
t.Fatalf("Validate: %v", err)
|
||||
}
|
||||
@ -94,7 +94,7 @@ func TestValidate_HappyPath(t *testing.T) {
|
||||
func TestValidate_EmptyPlaintextRejected(t *testing.T) {
|
||||
db, _, _ := sqlmock.New()
|
||||
defer db.Close()
|
||||
if _, _, err := Validate(context.Background(), db, ""); !errors.Is(err, ErrInvalidToken) {
|
||||
if _, _, _, err := Validate(context.Background(), db, ""); !errors.Is(err, ErrInvalidToken) {
|
||||
t.Errorf("empty plaintext should be ErrInvalidToken, got %v", err)
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ func TestValidate_UnknownHashErrInvalid(t *testing.T) {
|
||||
WithArgs(sqlmock.AnyArg()).
|
||||
WillReturnError(sql.ErrNoRows)
|
||||
|
||||
if _, _, err := Validate(context.Background(), db, "ghost"); !errors.Is(err, ErrInvalidToken) {
|
||||
if _, _, _, err := Validate(context.Background(), db, "ghost"); !errors.Is(err, ErrInvalidToken) {
|
||||
t.Errorf("unknown hash should be ErrInvalidToken, got %v", err)
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ func TestValidate_RevokedTokenNotAccepted(t *testing.T) {
|
||||
WithArgs(sqlmock.AnyArg()).
|
||||
WillReturnError(sql.ErrNoRows)
|
||||
|
||||
if _, _, err := Validate(context.Background(), db, "revoked-plaintext"); !errors.Is(err, ErrInvalidToken) {
|
||||
if _, _, _, err := Validate(context.Background(), db, "revoked-plaintext"); !errors.Is(err, ErrInvalidToken) {
|
||||
t.Errorf("revoked token should be ErrInvalidToken, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user