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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/featuretests/cmd_juju_register_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:
12
12
        jc "github.com/juju/testing/checkers"
13
13
        gc "gopkg.in/check.v1"
14
14
 
 
15
        "github.com/juju/juju/api"
15
16
        "github.com/juju/juju/cmd/juju/commands"
16
 
        "github.com/juju/juju/cmd/modelcmd"
17
17
        "github.com/juju/juju/juju"
18
18
        jujutesting "github.com/juju/juju/juju/testing"
19
19
        "github.com/juju/juju/testing"
36
36
}
37
37
 
38
38
func (s *cmdRegistrationSuite) TestAddUserAndRegister(c *gc.C) {
39
 
        c.Assert(modelcmd.WriteCurrentController("dummymodel"), jc.ErrorIsNil)
40
 
 
41
39
        // First, add user "bob", and record the "juju register" command
42
40
        // that is printed out.
43
41
        context := s.run(c, nil, "add-user", "bob", "Bob Dobbs")
47
45
User "Bob Dobbs \(bob\)" added
48
46
Please send this command to bob:
49
47
    juju register .*
 
48
 
 
49
"Bob Dobbs \(bob\)" has not been granted access to any models(.|\n)*
50
50
`[1:])
51
51
        jujuRegisterCommand := strings.Fields(strings.TrimSpace(
52
 
                stdout[strings.Index(stdout, "juju register"):],
 
52
                strings.SplitN(stdout[strings.Index(stdout, "juju register"):], "\n", 2)[0],
53
53
        ))
54
54
        c.Logf("%q", jujuRegisterCommand)
55
55
 
65
65
Confirm password: 
66
66
 
67
67
Welcome, bob. You are now logged into "bob-controller".
 
68
 
 
69
There are no models available. You can create models with
 
70
"juju create-model", or you can ask an administrator or owner
 
71
of a model to grant access to that model with "juju grant".
 
72
 
68
73
`[1:])
69
74
 
70
75
        // Make sure that the saved server details are sufficient to connect
71
76
        // to the api server.
72
 
        api, err := juju.NewAPIConnection(s.ControllerStore, "bob-controller", "bob@local", "", nil)
 
77
        accountDetails, err := s.ControllerStore.AccountByName("bob-controller", "bob@local")
 
78
        c.Assert(err, jc.ErrorIsNil)
 
79
        api, err := juju.NewAPIConnection(juju.NewAPIConnectionParams{
 
80
                Store:           s.ControllerStore,
 
81
                ControllerName:  "bob-controller",
 
82
                AccountDetails:  accountDetails,
 
83
                BootstrapConfig: noBootstrapConfig,
 
84
                DialOpts:        api.DefaultDialOpts(),
 
85
        })
73
86
        c.Assert(err, jc.ErrorIsNil)
74
87
        c.Assert(api.Close(), jc.ErrorIsNil)
75
88
}