-
Notifications
You must be signed in to change notification settings - Fork 66
/
web_server_test.go
49 lines (44 loc) · 1.24 KB
/
web_server_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
package main
import (
"net/http"
"testing"
"time"
"github.com/arrikto/oidc-authservice/common"
)
func TestWebServerDefault(t *testing.T) {
s := &WebServer{
TemplatePaths: []string{"web/templates/default"},
ProviderURL: "http://example.test",
ClientName: "Kubeflow",
ThemeURL: "themes/kubeflow",
Frontend: map[string]string{},
}
// Start web server
go func() {
t.Fatal(s.Start("localhost:8082"))
}()
time.Sleep(3 * time.Second)
baseURL := common.MustParseURL("http://localhost:8082")
homepage := baseURL.ResolveReference(common.MustParseURL("/site/homepage"))
afterLogout := baseURL.ResolveReference(common.MustParseURL("/site/after_logout"))
image := baseURL.ResolveReference(common.MustParseURL("/site/themes/kubeflow/styles.css"))
tests := []struct {
name string
url string
}{
{name: "homepage", url: homepage.String()},
{name: "afterLogout", url: afterLogout.String()},
{name: "image", url: image.String()},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
resp, err := http.DefaultClient.Get(test.url)
if err != nil {
t.Fatalf("Error making http request: %v", err)
}
if resp.StatusCode != 200 {
t.Fatalf("Got non-200 status code: %v", resp.StatusCode)
}
})
}
}