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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/cloud/addcredential_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
                        return nil, errors.NotFoundf("cloud %v", cloud)
45
45
                }
46
46
                return &jujucloud.Cloud{
47
 
                        Type:      "mock-addcredential-provider",
48
 
                        AuthTypes: s.authTypes,
 
47
                        Type:             "mock-addcredential-provider",
 
48
                        AuthTypes:        s.authTypes,
 
49
                        Endpoint:         "cloud-endpoint",
 
50
                        IdentityEndpoint: "cloud-identity-endpoint",
49
51
                }, nil
50
52
        }
51
53
}
207
209
        s.assertAddUserpassCredential(c, "fred\nuserpass\nuser\npassword\n", nil)
208
210
}
209
211
 
 
212
func (s *addCredentialSuite) TestAddCredentialInteractive(c *gc.C) {
 
213
        s.authTypes = []jujucloud.AuthType{"interactive"}
 
214
        s.schema = map[jujucloud.AuthType]jujucloud.CredentialSchema{
 
215
                "interactive": {{"username", jujucloud.CredentialAttr{}}},
 
216
        }
 
217
 
 
218
        stdin := strings.NewReader("bobscreds\nbob\n")
 
219
        ctx, err := s.run(c, stdin, "somecloud")
 
220
        c.Assert(err, jc.ErrorIsNil)
 
221
 
 
222
        c.Assert(testing.Stderr(ctx), gc.Equals, `
 
223
Enter credential name: Using auth-type "interactive".
 
224
Enter username: generating userpass credential
 
225
`[1:])
 
226
 
 
227
        // FinalizeCredential should have generated a userpass credential
 
228
        // based on the input from the interactive credential.
 
229
        c.Assert(s.store.Credentials, jc.DeepEquals, map[string]jujucloud.CloudCredential{
 
230
                "somecloud": {
 
231
                        AuthCredentials: map[string]jujucloud.Credential{
 
232
                                "bobscreds": jujucloud.NewCredential(jujucloud.UserPassAuthType, map[string]string{
 
233
                                        "username":             "bob",
 
234
                                        "password":             "cloud-endpoint",
 
235
                                        "application-password": "cloud-identity-endpoint",
 
236
                                }),
 
237
                        },
 
238
                },
 
239
        })
 
240
}
 
241
 
210
242
func (s *addCredentialSuite) TestAddCredentialReplace(c *gc.C) {
211
243
        s.store.Credentials = map[string]jujucloud.CloudCredential{
212
244
                "somecloud": {