From 4a1c699e93fb3da5fb637876c215e7ef3b651c7a Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Thu, 8 Apr 2021 10:22:34 -0700 Subject: [PATCH] Adds a new test --- web/__snapshots__/web.snapshot | 9 +++++++++ web/routes_test.go | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/web/__snapshots__/web.snapshot b/web/__snapshots__/web.snapshot index ab97f9b8..a7aed6fd 100644 --- a/web/__snapshots__/web.snapshot +++ b/web/__snapshots__/web.snapshot @@ -23,6 +23,15 @@ Location: /foobar/ Moved Permanently. +/* snapshot: Test_createRoutes_username_password */ +HTTP/1.1 307 Temporary Redirect +Connection: close +Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self'; manifest-src 'self'; connect-src 'self' api.github.com; require-trusted-types-for 'script' +Content-Type: text/html; charset=utf-8 +Location: /login + +Temporary Redirect. + /* snapshot: Test_createRoutes_version */ HTTP/1.1 200 OK Connection: close diff --git a/web/routes_test.go b/web/routes_test.go index fd30b493..60052b86 100644 --- a/web/routes_test.go +++ b/web/routes_test.go @@ -302,6 +302,16 @@ func Test_createRoutes_version(t *testing.T) { abide.AssertHTTPResponse(t, t.Name(), rr.Result()) } +func Test_createRoutes_username_password(t *testing.T) { + + handler := createHandler(nil, nil, Config{Base: "/", Username: "amir", Password: "password", Key: "key"}) + req, err := http.NewRequest("GET", "/", nil) + require.NoError(t, err, "NewRequest should not return an error.") + rr := httptest.NewRecorder() + handler.ServeHTTP(rr, req) + abide.AssertHTTPResponse(t, t.Name(), rr.Result()) +} + func createHandler(client docker.Client, content fs.FS, config Config) *mux.Router { if client == nil { client = new(MockedClient)