Newer
Older
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package issuerUtils
import "testing"
func TestCombineSubIssValid(t *testing.T) {
str := CombineSubIss("sub", "iss")
expected := "sub@iss"
if str != expected {
t.Errorf("Expected '%s', got '%s'", expected, str)
}
}
func TestCombineSubIssEmptyIss(t *testing.T) {
str := CombineSubIss("sub", "")
expected := ""
if str != expected {
t.Errorf("Expected '%s', got '%s'", expected, str)
}
}
func TestCombineSubIssEmptySub(t *testing.T) {
str := CombineSubIss("", "iss")
expected := ""
if str != expected {
t.Errorf("Expected '%s', got '%s'", expected, str)
}
}
func TestCompareIssuerURLBothEmpty(t *testing.T) {
if CompareIssuerURLs("", "") != true {
t.Errorf("Empty issuer urls should be equal")
}
}
func TestCompareIssuerURLOneEmpty(t *testing.T) {
a := "https://example.com"
b := ""
if CompareIssuerURLs(a, b) == true {
t.Errorf("An empty issuer url should not equal a non-empty")
}
if CompareIssuerURLs(b, a) == true {
t.Errorf("An empty issuer url should not equal a non-empty")
}
}
func TestCompareIssuerURLSame(t *testing.T) {
a := "https://example.com"
b := a
if CompareIssuerURLs(a, b) != true {
t.Errorf("Equal strings should be equal")
}
a = "https://example.com/"
b = a
if CompareIssuerURLs(a, b) != true {
t.Errorf("Equal strings should be equal")
}
}
func TestCompareIssuerURLDifferentSlash(t *testing.T) {
a := "https://example.com"
b := "https://example.com/"
if CompareIssuerURLs(a, b) != true {
t.Errorf("Issuer urls only differing in trailing slash should be equal")
}
if CompareIssuerURLs(b, a) != true {
t.Errorf("Issuer urls only differing in trailing slash should be equal")
}
}
func TestGetIssuerWithAndWithoutSlashEmpty(t *testing.T) {
iss0, iss1 := GetIssuerWithAndWithoutSlash("")
iss0Expected := ""
iss1Expected := "/"
if iss0 != iss0Expected {
t.Errorf("Iss0 Expected '%s', got '%s'", iss0Expected, iss0)
}
if iss1 != iss1Expected {
t.Errorf("Iss1 Expected '%s', got '%s'", iss1Expected, iss1)
}
}
func TestGetIssuerWithAndWithoutSlashTrailingSlash(t *testing.T) {
iss0, iss1 := GetIssuerWithAndWithoutSlash("https://example.com/")
iss0Expected := "https://example.com"
iss1Expected := "https://example.com/"
if iss0 != iss0Expected {
t.Errorf("Iss0 Expected '%s', got '%s'", iss0Expected, iss0)
}
if iss1 != iss1Expected {
t.Errorf("Iss1 Expected '%s', got '%s'", iss1Expected, iss1)
}
}
func TestGetIssuerWithAndWithoutSlashNoTrailingSlash(t *testing.T) {
iss0, iss1 := GetIssuerWithAndWithoutSlash("https://example.com")
iss0Expected := "https://example.com"
iss1Expected := "https://example.com/"
if iss0 != iss0Expected {
t.Errorf("Iss0 Expected '%s', got '%s'", iss0Expected, iss0)
}
if iss1 != iss1Expected {
t.Errorf("Iss1 Expected '%s', got '%s'", iss1Expected, iss1)
}
}