-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth_integration_test.go
53 lines (46 loc) · 1.77 KB
/
auth_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//go:build integration || integration_v0
// +build integration integration_v0
package fireboltgosdk
import (
"testing"
)
// TestAuthHappyPath tests normal authentication, and that the access token is actually set
func TestAuthHappyPath(t *testing.T) {
if len(getCachedAccessToken(clientMock.ClientID, clientMock.ApiEndpoint)) == 0 {
t.Errorf("Token is not set properly")
}
}
// TestAuthWrongCredential checks that authentication with wrong credentials returns an error
func TestAuthWrongCredential(t *testing.T) {
if _, err := Authenticate(&fireboltSettings{
clientID: "TestAuthWrongCredential",
clientSecret: "wrong_secret",
newVersion: true,
}, GetHostNameURL()); err == nil {
t.Errorf("Authentication with wrong credentials didn't return an error for service account authentication")
}
if _, err := Authenticate(&fireboltSettings{
clientID: "TestAuthWrongCredential",
clientSecret: "wrong_password",
newVersion: false,
}, GetHostNameURL()); err == nil {
t.Errorf("Authentication with wrong credentials didn't return an error for username/password authentication")
}
}
// TestAuthEmptyCredential checks that authentication with empty password returns an error
func TestAuthEmptyCredential(t *testing.T) {
if _, err := Authenticate(&fireboltSettings{
clientID: "TestAuthEmptyCredential",
clientSecret: "",
newVersion: true,
}, GetHostNameURL()); err == nil {
t.Errorf("Authentication with empty password didn't return an error for service account authentication")
}
if _, err := Authenticate(&fireboltSettings{
clientID: "TestAuthEmptyCredential",
clientSecret: "",
newVersion: false,
}, GetHostNameURL()); err == nil {
t.Errorf("Authentication with empty password didn't return an error for username/password authentication")
}
}