1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"github.com/juju/testing"
10
jc "github.com/juju/testing/checkers"
11
gc "gopkg.in/check.v1"
13
"github.com/juju/juju/cloud"
14
"github.com/juju/juju/environs"
15
"github.com/juju/juju/provider/azure"
16
"github.com/juju/juju/provider/azure/internal/azuretesting"
19
type AuthSuite struct {
20
testing.IsolationSuite
21
requests []*http.Request
24
var _ = gc.Suite(&AuthSuite{})
26
func (s *AuthSuite) TestAuthTokenServicePrincipalSecret(c *gc.C) {
27
spec := environs.CloudSpec{
31
Endpoint: "https://api.azurestack.local",
32
IdentityEndpoint: "https://graph.azurestack.local",
33
StorageEndpoint: "https://storage.azurestack.local",
34
Credential: fakeServicePrincipalCredential(),
36
senders := azuretesting.Senders{
39
token, err := azure.AuthToken(spec, &senders)
40
c.Assert(err, jc.ErrorIsNil)
41
c.Assert(token, gc.NotNil)
44
func (s *AuthSuite) TestAuthTokenInteractive(c *gc.C) {
45
spec := environs.CloudSpec{
49
Endpoint: "https://api.azurestack.local",
50
IdentityEndpoint: "https://graph.azurestack.local",
51
StorageEndpoint: "https://storage.azurestack.local",
52
Credential: fakeInteractiveCredential(),
54
senders := azuretesting.Senders{}
55
_, err := azure.AuthToken(spec, &senders)
56
c.Assert(err, gc.ErrorMatches, `auth-type "interactive" not supported`)
59
func fakeInteractiveCredential() *cloud.Credential {
60
cred := cloud.NewCredential("interactive", map[string]string{
61
"subscription-id": fakeSubscriptionId,