Skip to content

Commit

Permalink
remove tests for authorized route as it no longer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-anders committed Jul 11, 2017
1 parent 8642899 commit e5e63c2
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions nsqadmin/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,62 +119,6 @@ func TestPing(t *testing.T) {
test.Equal(t, []byte("OK"), body)
}

func TestAuthorizedWithoutAnyAdminUsers(t *testing.T) {
dataPath, nsqds, nsqlookupds, nsqadmin1 := bootstrapNSQCluster(t)
defer os.RemoveAll(dataPath)
defer nsqds[0].Exit()
defer nsqlookupds[0].Exit()
defer nsqadmin1.Exit()

client := http.Client{}
url := fmt.Sprintf("http://%s/authorized", nsqadmin1.RealHTTPAddr())
req, _ := http.NewRequest("GET", url, nil)
resp, err := client.Do(req)
test.Nil(t, err)
test.Equal(t, 200, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()

var res map[string]bool
err = json.Unmarshal(body, &res)
test.Nil(t, err)
test.Equal(t, res["authorized"], true)
}

func TestAuthorizedWithAdminUsers(t *testing.T) {
dataPath, nsqds, nsqlookupds, nsqadmin1 := bootstrapNSQClusterWithAuth(t, true)
defer os.RemoveAll(dataPath)
defer nsqds[0].Exit()
defer nsqlookupds[0].Exit()
defer nsqadmin1.Exit()

client := http.Client{}
url := fmt.Sprintf("http://%s/authorized", nsqadmin1.RealHTTPAddr())
req, _ := http.NewRequest("GET", url, nil)
resp, err := client.Do(req)
test.Nil(t, err)
test.Equal(t, 200, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()

var res map[string]bool
err = json.Unmarshal(body, &res)
test.Nil(t, err)
test.Equal(t, res["authorized"], false)

req, _ = http.NewRequest("GET", url, nil)
req.Header.Set("X-FORWARDED-USER", "matt")
resp, err = client.Do(req)
test.Nil(t, err)
test.Equal(t, 200, resp.StatusCode)
body, _ = ioutil.ReadAll(resp.Body)
resp.Body.Close()

err = json.Unmarshal(body, &res)
test.Nil(t, err)
test.Equal(t, res["authorized"], true)
}

func TestHTTPTopicsGET(t *testing.T) {
dataPath, nsqds, nsqlookupds, nsqadmin1 := bootstrapNSQCluster(t)
defer os.RemoveAll(dataPath)
Expand Down

0 comments on commit e5e63c2

Please sign in to comment.