Skip to content

Commit

Permalink
INFPLAT-1562 Fixes linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hendoxc committed Jan 9, 2025
1 parent 6f59cef commit d5529df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions pkg/beholder/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (a *authHeaderPerRPCCredentials) refresh() (map[string]string, error) {
// getHeaders returns the auth headers, refreshing them if they are expired
func (a *authHeaderPerRPCCredentials) getHeaders() (map[string]string, error) {
if time.Since(a.lastUpdated) > a.headerTTL {

a.mu.Lock()
defer a.mu.Unlock()

Expand Down Expand Up @@ -156,7 +155,6 @@ func BuildAuthHeadersV2(privKey ed25519.PrivateKey, config *AuthHeaderConfig) ma
}

pubKey := privKey.Public().(ed25519.PublicKey)

timestampUnixMsBytes := make([]byte, 8)
binary.BigEndian.PutUint64(timestampUnixMsBytes, uint64(config.timestamp))

Expand Down
15 changes: 8 additions & 7 deletions pkg/beholder/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func TestNewAuthHeaderProvider(t *testing.T) {
})

t.Run("custom config", func(t *testing.T) {

provider := AuthHeaderProviderConfig{
HeaderTTL: 2 * time.Minute,
RequireTransportSecurity: true,
Expand All @@ -182,13 +181,14 @@ func TestAuthHeaderPerRPCCredentials_Refresh(t *testing.T) {

t.Run("version 1", func(t *testing.T) {
creds := &authHeaderPerRPCCredentials{
privKey: csaPrivKey,
version: authHeaderVersion1,
refreshFunc: func() (map[string]string, error) {
return BuildAuthHeaders(csaPrivKey), nil
},
}
creds.refresh()

_, err := creds.refresh()
require.NoError(t, err)

headers, err := creds.getHeaders()
require.NoError(t, err)
Expand All @@ -202,13 +202,13 @@ func TestAuthHeaderPerRPCCredentials_Refresh(t *testing.T) {

t.Run("version 2", func(t *testing.T) {
creds := &authHeaderPerRPCCredentials{
privKey: csaPrivKey,
version: authHeaderVersion2,
refreshFunc: func() (map[string]string, error) {
return BuildAuthHeadersV2(csaPrivKey, nil), nil
},
}
creds.refresh()
_, err := creds.refresh()
require.NoError(t, err)

headers, err := creds.getHeaders()
require.NoError(t, err)
Expand All @@ -222,14 +222,15 @@ func TestAuthHeaderPerRPCCredentials_Refresh(t *testing.T) {

t.Run("refresh after TTL", func(t *testing.T) {
creds := &authHeaderPerRPCCredentials{
privKey: csaPrivKey,
headerTTL: 1 * time.Millisecond,
version: authHeaderVersion2,
refreshFunc: func() (map[string]string, error) {
return BuildAuthHeadersV2(csaPrivKey, nil), nil
},
}
creds.refresh()

_, err := creds.refresh()
require.NoError(t, err)

headers1, err := creds.getHeaders()
require.NoError(t, err)
Expand Down

0 comments on commit d5529df

Please sign in to comment.