forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_credentialmanager_test.go
50 lines (38 loc) · 1.39 KB
/
api_credentialmanager_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2018 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package featuretests
import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/api/client/credentialmanager"
"github.com/juju/juju/juju/testing"
)
// This suite only exists because no user facing calls exercise
// invalidate credential calls enough to expose serialisation bugs.
// If/when we have commands that would expose this,
// we should drop this suite and write a new command-based one.
type CredentialManagerSuite struct {
testing.JujuConnSuite
client *credentialmanager.Client
}
func (s *CredentialManagerSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
info := s.APIInfo(c)
userConn := s.OpenAPIAs(c, info.Tag, info.Password)
s.client = credentialmanager.NewClient(userConn)
}
func (s *CredentialManagerSuite) TearDownTest(c *gc.C) {
s.client.Close()
s.JujuConnSuite.TearDownTest(c)
}
func (s *CredentialManagerSuite) TestInvalidateModelCredential(c *gc.C) {
tag, set := s.Model.CloudCredentialTag()
c.Assert(set, jc.IsTrue)
credential, err := s.State.CloudCredential(tag)
c.Assert(err, jc.ErrorIsNil)
c.Assert(credential.IsValid(), jc.IsTrue)
c.Assert(s.client.InvalidateModelCredential("no reason really"), jc.ErrorIsNil)
credential, err = s.State.CloudCredential(tag)
c.Assert(err, jc.ErrorIsNil)
c.Assert(credential.IsValid(), jc.IsFalse)
}