Skip to content

Commit

Permalink
SDK-2422 added test
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Jan 9, 2024
1 parent 90f43ba commit 90be4ef
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions requests/signed_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,35 @@ func TestSignedRequest_WithPemFile_NotRSAKeyShouldError(t *testing.T) {
-----END RSA PUBLIC KEY-----`))
assert.ErrorContains(t, msg.Error, "not an RSA Private Key")
}

// TestAuthHeader tests the AuthHeader function.
func TestAuthHeader(t *testing.T) {
tests := []struct {
name string
clientSdkId string
expected map[string][]string
}{
{
name: "valid client SDK ID",
clientSdkId: "testSdkId",
expected: map[string][]string{"X-Yoti-Auth-Id": {"testSdkId"}},
},
{
name: "empty client SDK ID",
clientSdkId: "",
expected: map[string][]string{"X-Yoti-Auth-Id": {""}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

got := AuthHeader(tt.clientSdkId, &privateKey.PublicKey)

for key, value := range tt.expected {
if gotValue, exists := got[key]; !exists || len(gotValue) != 1 || gotValue[0] != value[0] {
t.Errorf("AuthHeader() = %v, want %v", got, tt.expected)
}
}
})
}
}

0 comments on commit 90be4ef

Please sign in to comment.