This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
64 lines (59 loc) · 1.43 KB
/
main_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
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"os"
"testing"
"github.com/afritzler/awesaml/pkg/utils"
)
func TestInitVarsNoEnv(t *testing.T) {
err := initVars()
if err == nil {
t.Errorf("No env should cause an error")
}
}
var testEnvs = map[string]string{
utils.EntityIDEnvName: "myEntityID",
utils.CertFileEnvName: "myservice.cert",
utils.KeyFileEnvName: "myservice.key",
utils.ServiceURLEnvName: "http://localhost:8000",
utils.IdpMetaDataURLEnvName: "http://myAwesomeIDP/saml2/metadata",
utils.ContentDirEnvName: "public",
utils.ServingPortEnvName: "8080",
}
func TestInitVarsWithEnvs(t *testing.T) {
for env, value := range testEnvs {
os.Setenv(env, value)
}
err := initVars()
if err != nil {
t.Errorf("%s", err)
return
}
if entityID != testEnvs[utils.EntityIDEnvName] {
t.Error("myEntityID is not set")
return
}
if certFile != testEnvs[utils.CertFileEnvName] {
t.Error("certFile is not set")
return
}
if certSecretName != "" {
t.Error("certSecretName should not be set")
return
}
if serviceURL != testEnvs[utils.ServiceURLEnvName] {
t.Error("serviceURL is not set")
return
}
if idpMetaDataURL != testEnvs[utils.IdpMetaDataURLEnvName] {
t.Error("idpMetaDataURL is not set")
return
}
if contentDir != testEnvs[utils.ContentDirEnvName] {
t.Error("contentDir is not set")
return
}
if servingPort != testEnvs[utils.ServingPortEnvName] {
t.Error("servingPort is not set")
return
}
}