コード例 #1
0
ファイル: discovery_test.go プロジェクト: bac/juju
func (*DiscoverySuite) TestDiscoverAuthorizationURIUnexpectedStatusCode(c *gc.C) {
	sender := mocks.NewSender()
	resp := mocks.NewResponseWithStatus("", http.StatusNotFound)
	sender.AppendResponse(resp)

	client := subscriptions.NewClient()
	client.Sender = sender
	_, err := azureauth.DiscoverAuthorizationURI(client, "subscription_id")
	c.Assert(err, gc.ErrorMatches, "expected unauthorized error response, got 404: .*")
}
コード例 #2
0
ファイル: discovery_test.go プロジェクト: bac/juju
func (*DiscoverySuite) TestDiscoverAuthorizationURIMissingHeader(c *gc.C) {
	sender := mocks.NewSender()
	resp := mocks.NewResponseWithStatus("", http.StatusUnauthorized)
	sender.AppendResponse(resp)

	client := subscriptions.NewClient()
	client.Sender = sender
	_, err := azureauth.DiscoverAuthorizationURI(client, "subscription_id")
	c.Assert(err, gc.ErrorMatches, `WWW-Authenticate header not found`)
}
コード例 #3
0
ファイル: discovery_test.go プロジェクト: bac/juju
func (*DiscoverySuite) TestDiscoverAuthorizationURIHeaderMismatch(c *gc.C) {
	sender := mocks.NewSender()
	resp := mocks.NewResponseWithStatus("", http.StatusUnauthorized)
	mocks.SetResponseHeaderValues(resp, "WWW-Authenticate", []string{`foo bar baz`})
	sender.AppendResponse(resp)

	client := subscriptions.NewClient()
	client.Sender = sender
	_, err := azureauth.DiscoverAuthorizationURI(client, "subscription_id")
	c.Assert(err, gc.ErrorMatches, `authorization_uri not found in WWW-Authenticate header \("foo bar baz"\)`)
}
コード例 #4
0
ファイル: discovery_test.go プロジェクト: bac/juju
func (*DiscoverySuite) TestDiscoverAuthorizationURI(c *gc.C) {
	sender := mocks.NewSender()
	resp := mocks.NewResponseWithStatus("", http.StatusUnauthorized)
	mocks.SetResponseHeaderValues(resp, "WWW-Authenticate", []string{
		`foo bar authorization_uri="https://testing.invalid/meep" baz`,
	})
	sender.AppendResponse(resp)

	client := subscriptions.NewClient()
	client.Sender = sender
	authURI, err := azureauth.DiscoverAuthorizationURI(client, "subscription_id")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(authURI, jc.DeepEquals, &url.URL{
		Scheme: "https",
		Host:   "testing.invalid",
		Path:   "/meep",
	})
}