~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/controller/showcontroller_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
        "github.com/juju/juju/cmd/juju/controller"
15
15
        "github.com/juju/juju/cmd/modelcmd"
 
16
        "github.com/juju/juju/jujuclient"
16
17
        "github.com/juju/juju/jujuclient/jujuclienttesting"
17
18
        "github.com/juju/juju/testing"
18
19
)
26
27
func (s *ShowControllerSuite) TestShowOneControllerOneInStore(c *gc.C) {
27
28
        s.controllersYaml = `controllers:
28
29
  local.mallards:
29
 
    servers: [maas-1-05.cluster.mallards]
30
30
    uuid: this-is-another-uuid
31
31
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
32
32
    ca-cert: this-is-another-ca-cert
36
36
        s.expectedOutput = `
37
37
local.mallards:
38
38
  details:
39
 
    servers: [maas-1-05.cluster.mallards]
40
39
    uuid: this-is-another-uuid
41
40
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
42
41
    ca-cert: this-is-another-ca-cert
62
61
func (s *ShowControllerSuite) TestShowControllerWithPasswords(c *gc.C) {
63
62
        s.controllersYaml = `controllers:
64
63
  local.mallards:
65
 
    servers: [maas-1-05.cluster.mallards]
66
64
    uuid: this-is-another-uuid
67
65
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
68
66
    ca-cert: this-is-another-ca-cert
72
70
        s.expectedOutput = `
73
71
local.mallards:
74
72
  details:
75
 
    servers: [maas-1-05.cluster.mallards]
76
73
    uuid: this-is-another-uuid
77
74
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
78
75
    ca-cert: this-is-another-ca-cert
97
94
        s.assertShowController(c, "local.mallards", "--show-passwords")
98
95
}
99
96
 
 
97
func (s *ShowControllerSuite) TestShowControllerWithBootstrapConfig(c *gc.C) {
 
98
        s.controllersYaml = `controllers:
 
99
  local.mallards:
 
100
    uuid: this-is-another-uuid
 
101
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
 
102
    ca-cert: this-is-another-ca-cert
 
103
`
 
104
        store := s.createTestClientStore(c)
 
105
        store.BootstrapConfig["local.mallards"] = jujuclient.BootstrapConfig{
 
106
                Config: map[string]interface{}{
 
107
                        "name":  "admin",
 
108
                        "type":  "maas",
 
109
                        "extra": "value",
 
110
                },
 
111
                Credential:    "my-credential",
 
112
                Cloud:         "mallards",
 
113
                CloudRegion:   "mallards1",
 
114
                CloudEndpoint: "http://mallards.local/MAAS",
 
115
        }
 
116
 
 
117
        s.expectedOutput = `
 
118
local.mallards:
 
119
  details:
 
120
    uuid: this-is-another-uuid
 
121
    api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
 
122
    ca-cert: this-is-another-ca-cert
 
123
  accounts:
 
124
    admin@local:
 
125
      user: admin@local
 
126
      models:
 
127
        admin:
 
128
          uuid: abc
 
129
        my-model:
 
130
          uuid: def
 
131
      current-model: my-model
 
132
    bob@local:
 
133
      user: bob@local
 
134
    bob@remote:
 
135
      user: bob@remote
 
136
  current-account: admin@local
 
137
  bootstrap-config:
 
138
    config:
 
139
      extra: value
 
140
    cloud: mallards
 
141
    cloud-type: maas
 
142
    region: mallards1
 
143
    endpoint: http://mallards.local/MAAS
 
144
    credential: my-credential
 
145
`[1:]
 
146
 
 
147
        s.assertShowController(c, "local.mallards")
 
148
}
 
149
 
100
150
func (s *ShowControllerSuite) TestShowOneControllerManyInStore(c *gc.C) {
101
151
        s.createTestClientStore(c)
102
152
 
103
153
        s.expectedOutput = `
104
154
local.aws-test:
105
155
  details:
106
 
    servers: [instance-1-2-4.useast.aws.com]
107
156
    uuid: this-is-the-aws-test-uuid
108
157
    api-endpoints: [this-is-aws-test-of-many-api-endpoints]
109
158
    ca-cert: this-is-aws-test-ca-cert
123
172
        s.expectedOutput = `
124
173
local.aws-test:
125
174
  details:
126
 
    servers: [instance-1-2-4.useast.aws.com]
127
175
    uuid: this-is-the-aws-test-uuid
128
176
    api-endpoints: [this-is-aws-test-of-many-api-endpoints]
129
177
    ca-cert: this-is-aws-test-ca-cert
136
184
      current-model: admin
137
185
local.mark-test-prodstack:
138
186
  details:
139
 
    servers: [vm-23532.prodstack.canonical.com, great.test.server.hostname.co.nz]
140
187
    uuid: this-is-a-uuid
141
188
    api-endpoints: [this-is-one-of-many-api-endpoints]
142
189
    ca-cert: this-is-a-ca-cert
152
199
        s.createTestClientStore(c)
153
200
 
154
201
        s.expectedOutput = `
155
 
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
 
202
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
156
203
`[1:]
157
204
 
158
205
        s.assertShowController(c, "--format", "json", "local.aws-test")
161
208
func (s *ShowControllerSuite) TestShowControllerJsonMany(c *gc.C) {
162
209
        s.createTestClientStore(c)
163
210
        s.expectedOutput = `
164
 
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}},"local.mark-test-prodstack":{"details":{"servers":["vm-23532.prodstack.canonical.com","great.test.server.hostname.co.nz"],"uuid":"this-is-a-uuid","api-endpoints":["this-is-one-of-many-api-endpoints"],"ca-cert":"this-is-a-ca-cert"},"accounts":{"admin@local":{"user":"admin@local"}}}}
 
211
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}},"local.mark-test-prodstack":{"details":{"uuid":"this-is-a-uuid","api-endpoints":["this-is-one-of-many-api-endpoints"],"ca-cert":"this-is-a-ca-cert"},"accounts":{"admin@local":{"user":"admin@local"}}}}
165
212
`[1:]
166
213
        s.assertShowController(c, "--format", "json", "local.aws-test", "local.mark-test-prodstack")
167
214
}
183
230
        s.createTestClientStore(c)
184
231
 
185
232
        s.expectedOutput = `
186
 
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
 
233
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
187
234
`[1:]
188
235
        err := modelcmd.WriteCurrentController("local.aws-test")
189
236
        c.Assert(err, jc.ErrorIsNil)