18785: remove the documentation for the single host, multiple hostnames
[arvados.git] / services / keep-web / status_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package main
6
7 import (
8         "encoding/json"
9         "net/http"
10         "net/http/httptest"
11         "net/url"
12
13         "git.arvados.org/arvados.git/sdk/go/arvadostest"
14         "git.arvados.org/arvados.git/sdk/go/ctxlog"
15         "gopkg.in/check.v1"
16 )
17
18 func (s *UnitSuite) TestStatus(c *check.C) {
19         h := handler{Config: newConfig(ctxlog.TestLogger(c), s.Config)}
20         u, _ := url.Parse("http://keep-web.example/status.json")
21         req := &http.Request{
22                 Method:     "GET",
23                 Host:       u.Host,
24                 URL:        u,
25                 RequestURI: u.RequestURI(),
26         }
27         resp := httptest.NewRecorder()
28         h.ServeHTTP(resp, req)
29         c.Check(resp.Code, check.Equals, http.StatusOK)
30
31         var status map[string]interface{}
32         err := json.NewDecoder(resp.Body).Decode(&status)
33         c.Check(err, check.IsNil)
34         c.Check(status["Version"], check.Not(check.Equals), "")
35 }
36
37 func (s *IntegrationSuite) TestNoStatusFromVHost(c *check.C) {
38         u, _ := url.Parse("http://" + arvadostest.FooCollection + "--keep-web.example/status.json")
39         req := &http.Request{
40                 Method:     "GET",
41                 Host:       u.Host,
42                 URL:        u,
43                 RequestURI: u.RequestURI(),
44                 Header: http.Header{
45                         "Authorization": {"OAuth2 " + arvadostest.ActiveToken},
46                 },
47         }
48         resp := httptest.NewRecorder()
49         s.testServer.Handler.ServeHTTP(resp, req)
50         c.Check(resp.Code, check.Equals, http.StatusNotFound)
51 }