-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_test.go
More file actions
43 lines (36 loc) · 945 Bytes
/
Copy pathauth_test.go
File metadata and controls
43 lines (36 loc) · 945 Bytes
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
package main
import "testing"
func TestIsAuthConfigured(t *testing.T) {
configMu.Lock()
appConfig.ApiURL = ""
appConfig.ApiKey = ""
appConfig.ApiSecret = ""
appConfig.ApiToken = ""
configMu.Unlock()
if IsAuthConfigured() {
t.Error("should be false with no credentials")
}
configMu.Lock()
appConfig.ApiURL = "https://example.com"
appConfig.ApiKey = "key123"
appConfig.ApiSecret = "secret456"
configMu.Unlock()
if !IsAuthConfigured() {
t.Error("should be true with API key + secret")
}
}
func TestAuthState(t *testing.T) {
configMu.Lock()
appConfig.ApiURL = "https://example.com"
appConfig.ApiKey = "key"
appConfig.ApiSecret = "secret"
appConfig.Whitelabel = WhitelabelConfig{Name: "TestCo", ID: 42}
configMu.Unlock()
state := GetAuthState()
if !state.Configured {
t.Error("configured should be true")
}
if state.WhitelabelName != "TestCo" {
t.Errorf("wl name = %q, want TestCo", state.WhitelabelName)
}
}