vmc 0.5.0.beta.7 → 0.5.0.beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1277 -746
- data/Rakefile +22 -23
- data/lib/vmc/cli.rb +21 -27
- data/lib/vmc/cli/app/push.rb +1 -0
- data/lib/vmc/cli/app/push/create.rb +3 -2
- data/lib/vmc/cli/app/push/sync.rb +11 -8
- data/lib/vmc/cli/app/scale.rb +19 -17
- data/lib/vmc/cli/domain/map.rb +55 -0
- data/lib/vmc/cli/domain/unmap.rb +56 -0
- data/lib/vmc/cli/route/map.rb +74 -0
- data/lib/vmc/cli/route/unmap.rb +94 -0
- data/lib/vmc/cli/service/create.rb +4 -1
- data/lib/vmc/cli/start/base.rb +2 -2
- data/lib/vmc/cli/start/login.rb +5 -2
- data/lib/vmc/cli/start/target.rb +4 -3
- data/lib/vmc/cli/user/base.rb +19 -0
- data/lib/vmc/cli/user/passwd.rb +7 -19
- data/lib/vmc/cli/{start → user}/register.rb +12 -23
- data/lib/vmc/constants.rb +1 -1
- data/lib/vmc/test_support.rb +4 -0
- data/lib/vmc/test_support/command_helper.rb +38 -0
- data/{spec/support → lib/vmc/test_support}/common_input_examples.rb +0 -0
- data/lib/vmc/test_support/fake_home_dir.rb +16 -0
- data/lib/vmc/test_support/interact_helper.rb +29 -0
- data/lib/vmc/version.rb +1 -1
- data/spec/features/new_user_flow_spec.rb +43 -51
- data/spec/spec_helper.rb +24 -12
- data/spec/vmc/cli/app/instances_spec.rb +3 -8
- data/spec/vmc/cli/app/push/create_spec.rb +10 -7
- data/spec/vmc/cli/app/push_spec.rb +1 -1
- data/spec/vmc/cli/app/rename_spec.rb +1 -1
- data/spec/vmc/cli/app/scale_spec.rb +81 -0
- data/spec/vmc/cli/app/stats_spec.rb +3 -7
- data/spec/vmc/cli/domain/map_spec.rb +140 -0
- data/spec/vmc/cli/domain/unmap_spec.rb +73 -0
- data/spec/vmc/cli/organization/orgs_spec.rb +13 -16
- data/spec/vmc/cli/organization/rename_spec.rb +1 -1
- data/spec/vmc/cli/route/map_spec.rb +142 -0
- data/spec/vmc/cli/route/unmap_spec.rb +215 -0
- data/spec/vmc/cli/service/rename_spec.rb +1 -1
- data/spec/vmc/cli/space/rename_spec.rb +15 -18
- data/spec/vmc/cli/space/spaces_spec.rb +18 -25
- data/spec/vmc/cli/start/info_spec.rb +44 -46
- data/spec/vmc/cli/start/login_spec.rb +40 -0
- data/spec/vmc/cli/user/create_spec.rb +54 -0
- data/spec/vmc/cli/user/passwd_spec.rb +7 -14
- data/spec/vmc/cli/{start → user}/register_spec.rb +26 -22
- data/spec/vmc/cli_spec.rb +164 -6
- metadata +46 -39
- data/lib/vmc/cli/app/routes.rb +0 -100
- data/lib/vmc/cli/domain/add_domain.rb +0 -25
- data/lib/vmc/cli/domain/create_domain.rb +0 -28
- data/lib/vmc/cli/domain/delete_domain.rb +0 -56
- data/lib/vmc/cli/domain/remove_domain.rb +0 -28
- data/lib/vmc/cli/route/create_route.rb +0 -49
- data/lib/vmc/cli/route/delete.rb +0 -47
- data/spec/support/feature_helpers.rb +0 -16
- data/spec/support/interact_helpers.rb +0 -27
- data/spec/vmc/cli/route/delete_route_spec.rb +0 -162
@@ -2,10 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'stringio'
|
3
3
|
|
4
4
|
describe VMC::Space::Spaces do
|
5
|
-
let(:
|
6
|
-
let(:inputs) { {} }
|
7
|
-
let(:given) { {} }
|
8
|
-
let(:output) { StringIO.new }
|
5
|
+
let(:full) { false }
|
9
6
|
let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
|
10
7
|
let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
|
11
8
|
let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
|
@@ -14,18 +11,12 @@ describe VMC::Space::Spaces do
|
|
14
11
|
let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
|
15
12
|
|
16
13
|
before do
|
17
|
-
any_instance_of
|
14
|
+
any_instance_of described_class do |cli|
|
18
15
|
stub(cli).client { client }
|
19
16
|
stub(cli).precondition { nil }
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
|
-
subject do
|
24
|
-
with_output_to output do
|
25
|
-
Mothership.new.invoke(:spaces, inputs, given, global)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
20
|
describe 'metadata' do
|
30
21
|
let(:command) { Mothership.commands[:spaces] }
|
31
22
|
|
@@ -45,19 +36,21 @@ describe VMC::Space::Spaces do
|
|
45
36
|
end
|
46
37
|
end
|
47
38
|
|
39
|
+
subject { vmc %W[spaces --#{bool_flag(:full)} --no-quiet] }
|
40
|
+
|
48
41
|
it 'should have the correct first two lines' do
|
49
42
|
subject
|
50
43
|
|
51
|
-
|
52
|
-
expect(
|
53
|
-
expect(
|
44
|
+
stdout.rewind
|
45
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
46
|
+
expect(stdout.readline).to eq "\n"
|
54
47
|
end
|
55
48
|
|
56
49
|
context 'when there are no spaces' do
|
57
50
|
let(:spaces) { [] }
|
58
51
|
|
59
52
|
context 'and the full flag is given' do
|
60
|
-
let(:
|
53
|
+
let(:full) { true }
|
61
54
|
|
62
55
|
it 'displays yaml-style output with all space details' do
|
63
56
|
any_instance_of VMC::Space::Spaces do |spaces|
|
@@ -71,16 +64,16 @@ describe VMC::Space::Spaces do
|
|
71
64
|
it 'should show only the progress' do
|
72
65
|
subject
|
73
66
|
|
74
|
-
|
75
|
-
expect(
|
76
|
-
expect(
|
67
|
+
stdout.rewind
|
68
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
69
|
+
expect(stdout).to be_eof
|
77
70
|
end
|
78
71
|
end
|
79
72
|
end
|
80
73
|
|
81
74
|
context 'when there are spaces' do
|
82
75
|
context 'and the full flag is given' do
|
83
|
-
let(:
|
76
|
+
let(:full) { true }
|
84
77
|
|
85
78
|
it 'displays yaml-style output with all space details' do
|
86
79
|
any_instance_of VMC::Space::Spaces do |spaces|
|
@@ -96,15 +89,15 @@ describe VMC::Space::Spaces do
|
|
96
89
|
it 'displays tabular output with names, spaces and domains' do
|
97
90
|
subject
|
98
91
|
|
99
|
-
|
100
|
-
|
101
|
-
|
92
|
+
stdout.rewind
|
93
|
+
stdout.readline
|
94
|
+
stdout.readline
|
102
95
|
|
103
|
-
expect(
|
96
|
+
expect(stdout.readline).to match /name\s+apps\s+services/
|
104
97
|
spaces.sort_by(&:name).each do |space|
|
105
|
-
expect(
|
98
|
+
expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
|
106
99
|
end
|
107
|
-
expect(
|
100
|
+
expect(stdout).to be_eof
|
108
101
|
end
|
109
102
|
end
|
110
103
|
end
|
@@ -1,36 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe VMC::Start::Info do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:
|
4
|
+
let(:frameworks) { false }
|
5
|
+
let(:runtimes) { false }
|
6
|
+
let(:services) { false }
|
7
|
+
let(:all) { false }
|
8
8
|
|
9
|
-
let(:client)
|
9
|
+
let(:client) do
|
10
10
|
fake_client :frameworks => fake_list(:framework, 3),
|
11
11
|
:runtimes => fake_list(:runtime, 3),
|
12
|
-
:services => fake_list(:service, 3)
|
13
|
-
|
12
|
+
:services => fake_list(:service, 3),
|
13
|
+
:token => CFoundry::AuthToken.new("bearer some-access-token")
|
14
|
+
end
|
14
15
|
|
15
|
-
let(:target_info)
|
16
|
-
{
|
16
|
+
let(:target_info) do
|
17
|
+
{:description => "Some description",
|
17
18
|
:version => 2,
|
18
19
|
:support => "http://example.com"
|
19
20
|
}
|
20
|
-
|
21
|
+
end
|
21
22
|
|
22
23
|
before do
|
23
|
-
any_instance_of
|
24
|
+
any_instance_of described_class do |cli|
|
24
25
|
stub(cli).client { client }
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
subject do
|
29
|
-
with_output_to output do
|
30
|
-
Mothership.new.invoke(:info, inputs, given, global)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
29
|
describe 'metadata' do
|
35
30
|
let(:command) { Mothership.commands[:info] }
|
36
31
|
|
@@ -57,23 +52,26 @@ describe VMC::Start::Info do
|
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
55
|
+
|
56
|
+
subject { vmc %W[info --#{bool_flag(:frameworks)} --#{bool_flag(:runtimes)} --#{bool_flag(:services)} --#{bool_flag(:all)} --no-force --no-quiet] }
|
57
|
+
|
60
58
|
context 'when given no flags' do
|
61
59
|
it "displays target information" do
|
62
60
|
mock(client).info { target_info }
|
63
61
|
|
64
62
|
subject
|
65
63
|
|
66
|
-
|
67
|
-
expect(
|
68
|
-
expect(
|
69
|
-
expect(
|
70
|
-
expect(
|
71
|
-
expect(
|
64
|
+
stdout.rewind
|
65
|
+
expect(stdout.readline).to eq "Some description\n"
|
66
|
+
expect(stdout.readline).to eq "\n"
|
67
|
+
expect(stdout.readline).to eq "target: #{client.target}\n"
|
68
|
+
expect(stdout.readline).to eq " version: 2\n"
|
69
|
+
expect(stdout.readline).to eq " support: http://example.com\n"
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
73
|
context 'when given --frameworks' do
|
76
|
-
let(:
|
74
|
+
let(:frameworks) { true }
|
77
75
|
|
78
76
|
it 'does not grab /info' do
|
79
77
|
dont_allow(client).info
|
@@ -83,19 +81,19 @@ describe VMC::Start::Info do
|
|
83
81
|
it 'lists frameworks on the target' do
|
84
82
|
subject
|
85
83
|
|
86
|
-
|
87
|
-
expect(
|
88
|
-
expect(
|
89
|
-
expect(
|
84
|
+
stdout.rewind
|
85
|
+
expect(stdout.readline).to match /Getting frameworks.*OK/
|
86
|
+
expect(stdout.readline).to eq "\n"
|
87
|
+
expect(stdout.readline).to match /framework\s+description/
|
90
88
|
|
91
89
|
client.frameworks.sort_by(&:name).each do |f|
|
92
|
-
expect(
|
90
|
+
expect(stdout.readline).to match /#{f.name}\s+#{f.description}/
|
93
91
|
end
|
94
92
|
end
|
95
93
|
end
|
96
94
|
|
97
95
|
context 'when given --runtimes' do
|
98
|
-
let(:
|
96
|
+
let(:runtimes) { true }
|
99
97
|
|
100
98
|
it 'does not grab /info' do
|
101
99
|
dont_allow(client).info
|
@@ -105,19 +103,19 @@ describe VMC::Start::Info do
|
|
105
103
|
it 'lists runtimes on the target' do
|
106
104
|
subject
|
107
105
|
|
108
|
-
|
109
|
-
expect(
|
110
|
-
expect(
|
111
|
-
expect(
|
106
|
+
stdout.rewind
|
107
|
+
expect(stdout.readline).to match /Getting runtimes.*OK/
|
108
|
+
expect(stdout.readline).to eq "\n"
|
109
|
+
expect(stdout.readline).to match /runtime\s+description/
|
112
110
|
|
113
111
|
client.runtimes.sort_by(&:name).each do |r|
|
114
|
-
expect(
|
112
|
+
expect(stdout.readline).to match /#{r.name}\s+#{r.description}/
|
115
113
|
end
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
119
117
|
context 'when given --services' do
|
120
|
-
let(:
|
118
|
+
let(:services) { true }
|
121
119
|
|
122
120
|
it 'does not grab /info' do
|
123
121
|
dont_allow(client).info
|
@@ -127,29 +125,29 @@ describe VMC::Start::Info do
|
|
127
125
|
it 'lists services on the target' do
|
128
126
|
subject
|
129
127
|
|
130
|
-
|
131
|
-
expect(
|
132
|
-
expect(
|
133
|
-
expect(
|
128
|
+
stdout.rewind
|
129
|
+
expect(stdout.readline).to match /Getting services.*OK/
|
130
|
+
expect(stdout.readline).to eq "\n"
|
131
|
+
expect(stdout.readline).to match /service\s+version\s+provider\s+plans\s+description/
|
134
132
|
|
135
133
|
client.services.sort_by(&:label).each do |s|
|
136
|
-
expect(
|
134
|
+
expect(stdout.readline).to match /#{s.label}\s+#{s.version}\s+#{s.provider}.+#{s.description}/
|
137
135
|
end
|
138
136
|
end
|
139
137
|
end
|
140
138
|
|
141
139
|
context 'when given --all' do
|
142
|
-
let(:
|
140
|
+
let(:all) { true }
|
143
141
|
|
144
142
|
it 'combines --frameworks --runtimes and --services' do
|
145
143
|
mock(client).info { target_info }
|
146
144
|
|
147
145
|
subject
|
148
146
|
|
149
|
-
|
150
|
-
expect(
|
151
|
-
expect(
|
152
|
-
expect(
|
147
|
+
stdout.rewind
|
148
|
+
expect(stdout.readline).to match /Getting runtimes.*OK/
|
149
|
+
expect(stdout.readline).to match /Getting frameworks.*OK/
|
150
|
+
expect(stdout.readline).to match /Getting services.*OK/
|
153
151
|
end
|
154
152
|
end
|
155
153
|
end
|
@@ -28,4 +28,44 @@ describe VMC::Start::Login do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe "running the command" do
|
33
|
+
use_fake_home_dir { home_dir }
|
34
|
+
|
35
|
+
let(:home_dir) do
|
36
|
+
tmp_root = Dir.tmpdir
|
37
|
+
FileUtils.cp_r(File.expand_path("#{SPEC_ROOT}/fixtures/fake_home_dirs/new"), tmp_root)
|
38
|
+
"#{tmp_root}/new"
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:auth_token) { CFoundry::AuthToken.new("bearer some-new-access-token", "some-new-refresh-token") }
|
42
|
+
|
43
|
+
after { FileUtils.rm_rf home_dir }
|
44
|
+
|
45
|
+
before do
|
46
|
+
any_instance_of(CFoundry::V2::Client) do |client|
|
47
|
+
stub(client).login("my-username", "my-password") { auth_token }
|
48
|
+
stub(client).login_prompts do
|
49
|
+
{
|
50
|
+
:username => ["text", "Username"],
|
51
|
+
:password => ["password", "8-digit PIN"]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
stub(client).organizations { [] }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
subject { vmc ["login", "--no-force"] }
|
59
|
+
|
60
|
+
it "logs in with the provided credentials and saves the token data to the YAML file" do
|
61
|
+
stub_ask("Username", {}) { "my-username" }
|
62
|
+
stub_ask("8-digit PIN", { :echo => "*", :forget => true}) { "my-password" }
|
63
|
+
|
64
|
+
subject
|
65
|
+
|
66
|
+
tokens_yaml = YAML.load_file(File.expand_path("~/.vmc/tokens.yml"))
|
67
|
+
expect(tokens_yaml["https://api.some-domain.com"][:token]).to eq("bearer some-new-access-token")
|
68
|
+
expect(tokens_yaml["https://api.some-domain.com"][:refresh_token]).to eq("some-new-refresh-token")
|
69
|
+
end
|
70
|
+
end
|
31
71
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::User::Create do
|
4
|
+
let(:client) { fake_client }
|
5
|
+
|
6
|
+
before do
|
7
|
+
any_instance_of(described_class) { |cli| stub(cli).client { client } }
|
8
|
+
stub(client).register
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { vmc %W[create-user --#{bool_flag(:force)}] }
|
12
|
+
|
13
|
+
context "when the user is not logged in" do
|
14
|
+
let(:force) { true }
|
15
|
+
|
16
|
+
before do
|
17
|
+
stub(client).logged_in? { false }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "tells the user to log in" do
|
21
|
+
subject
|
22
|
+
expect(stderr.string).to include("Please log in")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the user is logged in" do
|
27
|
+
let(:force) { false }
|
28
|
+
|
29
|
+
before do
|
30
|
+
stub(client).logged_in? { true }
|
31
|
+
stub_ask("Email") { "some-angry-dude@example.com" }
|
32
|
+
stub_ask("Password", anything) { "password1" }
|
33
|
+
stub_ask("Verify Password", anything) { confirmation }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when the password does not match its confirmation" do
|
37
|
+
let(:confirmation) { "wrong" }
|
38
|
+
|
39
|
+
it "displays an error message" do
|
40
|
+
subject
|
41
|
+
expect(stderr.string).to include("Passwords don't match")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the password matches its confirmation" do
|
46
|
+
let(:confirmation) { "password1" }
|
47
|
+
|
48
|
+
it "creates a user" do
|
49
|
+
mock(client).register("some-angry-dude@example.com", "password1")
|
50
|
+
subject
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -22,34 +22,27 @@ describe VMC::User::Passwd do
|
|
22
22
|
|
23
23
|
describe '#passwd' do
|
24
24
|
let(:client) { fake_client }
|
25
|
-
let(:output) { StringIO.new }
|
26
|
-
let(:out) { output.string }
|
27
25
|
let(:old_password) { "old" }
|
28
26
|
let(:new_password) { "password" }
|
29
27
|
let(:verify_password) { new_password }
|
30
28
|
let(:score) { :strong }
|
31
|
-
|
32
29
|
let(:guid) { random_string("my-object-guid") }
|
33
30
|
let(:user_model) { fake_model { attribute :password, :object } }
|
34
31
|
let(:user_object) { user_model.new(guid, client) }
|
35
32
|
let(:user) { user_object.fake(:password => 'foo') }
|
36
33
|
|
37
34
|
before do
|
38
|
-
|
39
|
-
any_instance_of(VMC::CLI) do |cli|
|
35
|
+
any_instance_of described_class do |cli|
|
40
36
|
stub(cli).client { client }
|
41
37
|
stub(cli).precondition { nil }
|
42
38
|
end
|
39
|
+
stub(client).logged_in? { true }
|
43
40
|
stub(client).current_user { user }
|
44
41
|
stub(client).register
|
45
42
|
stub(client).base.stub!.uaa.stub!.password_score(new_password) { score }
|
46
43
|
end
|
47
44
|
|
48
|
-
subject
|
49
|
-
with_output_to output do
|
50
|
-
VMC::CLI.start %W(passwd --password #{old_password} --new-password #{new_password} --verify #{verify_password} --force --debug)
|
51
|
-
end
|
52
|
-
end
|
45
|
+
subject { vmc %W[passwd --password #{old_password} --new-password #{new_password} --verify #{verify_password} --no-force --debug] }
|
53
46
|
|
54
47
|
context 'when the passwords dont match' do
|
55
48
|
let(:verify_password) { "other_password" }
|
@@ -58,12 +51,12 @@ describe VMC::User::Passwd do
|
|
58
51
|
|
59
52
|
it 'fails' do
|
60
53
|
subject
|
61
|
-
expect(
|
54
|
+
expect(stderr.string).to include "Passwords do not match."
|
62
55
|
end
|
63
56
|
|
64
57
|
it "doesn't print out the score" do
|
65
58
|
subject
|
66
|
-
expect(
|
59
|
+
expect(stdout.string).not_to include "strength"
|
67
60
|
end
|
68
61
|
|
69
62
|
it "doesn't log in or register" do
|
@@ -81,7 +74,7 @@ describe VMC::User::Passwd do
|
|
81
74
|
|
82
75
|
it 'prints out the password score' do
|
83
76
|
subject
|
84
|
-
expect(
|
77
|
+
expect(stdout.string).to include "Your password strength is: strong"
|
85
78
|
end
|
86
79
|
|
87
80
|
it 'changes the password' do
|
@@ -97,7 +90,7 @@ describe VMC::User::Passwd do
|
|
97
90
|
|
98
91
|
it 'prints out the password score' do
|
99
92
|
subject
|
100
|
-
expect(
|
93
|
+
expect(stderr.string).to include "Your password strength is: weak"
|
101
94
|
end
|
102
95
|
|
103
96
|
it "doesn't change the password" do
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VMC::
|
3
|
+
describe VMC::User::Register do
|
4
4
|
describe 'metadata' do
|
5
5
|
let(:command) { Mothership.commands[:register] }
|
6
6
|
|
7
7
|
describe 'command' do
|
8
8
|
subject { command }
|
9
9
|
its(:description) { should eq "Create a user and log in" }
|
10
|
-
it { expect(Mothership::Help.group(:
|
10
|
+
it { expect(Mothership::Help.group(:admin, :user)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
13
|
include_examples 'inputs must have descriptions'
|
@@ -24,18 +24,15 @@ describe VMC::Start::Register do
|
|
24
24
|
|
25
25
|
describe '#register' do
|
26
26
|
let(:client) { fake_client }
|
27
|
-
let(:
|
28
|
-
let(:
|
29
|
-
let(:email) { "a@b.com" }
|
30
|
-
let(:password) { "password" }
|
27
|
+
let(:email) { 'a@b.com' }
|
28
|
+
let(:password) { 'password' }
|
31
29
|
let(:verify_password) { password }
|
32
30
|
let(:force) { false }
|
33
31
|
let(:login) { false }
|
34
32
|
let(:score) { :strong }
|
35
33
|
|
36
34
|
before do
|
37
|
-
|
38
|
-
any_instance_of(VMC::CLI) do |cli|
|
35
|
+
any_instance_of described_class do |cli|
|
39
36
|
stub(cli).client { client }
|
40
37
|
stub(cli).precondition { nil }
|
41
38
|
end
|
@@ -43,11 +40,7 @@ describe VMC::Start::Register do
|
|
43
40
|
stub(client).base.stub!.uaa.stub!.password_score(password) { score }
|
44
41
|
end
|
45
42
|
|
46
|
-
subject
|
47
|
-
with_output_to output do
|
48
|
-
VMC::CLI.start %W(register --email #{email} --password #{password} --verify #{verify_password} #{login ? '--login' : '--no-login'} #{force ? '--force' : '--no-force'} --debug)
|
49
|
-
end
|
50
|
-
end
|
43
|
+
subject { vmc %W[register --email #{email} --password #{password} --verify #{verify_password} --#{bool_flag(:login)} --#{bool_flag(:force)}] }
|
51
44
|
|
52
45
|
context 'when the passwords dont match' do
|
53
46
|
let(:verify_password) { "other_password" }
|
@@ -56,17 +49,17 @@ describe VMC::Start::Register do
|
|
56
49
|
|
57
50
|
it 'fails' do
|
58
51
|
subject
|
59
|
-
expect(
|
52
|
+
expect(stderr.string).to include "Passwords do not match."
|
60
53
|
end
|
61
54
|
|
62
55
|
it "doesn't print out the score" do
|
63
56
|
subject
|
64
|
-
expect(
|
57
|
+
expect(stdout.string).not_to include "strength"
|
65
58
|
end
|
66
59
|
|
67
60
|
it "doesn't log in or register" do
|
68
61
|
dont_allow(client).register
|
69
|
-
any_instance_of
|
62
|
+
any_instance_of(described_class) do |register|
|
70
63
|
dont_allow(register).invoke
|
71
64
|
end
|
72
65
|
subject
|
@@ -78,7 +71,7 @@ describe VMC::Start::Register do
|
|
78
71
|
it "doesn't verify the password" do
|
79
72
|
mock(client).register(email, password)
|
80
73
|
subject
|
81
|
-
expect(
|
74
|
+
expect(stderr.string).not_to include "Passwords do not match."
|
82
75
|
end
|
83
76
|
end
|
84
77
|
end
|
@@ -88,7 +81,7 @@ describe VMC::Start::Register do
|
|
88
81
|
|
89
82
|
it 'prints out the password score' do
|
90
83
|
subject
|
91
|
-
expect(
|
84
|
+
expect(stdout.string).to include "Your password strength is: strong"
|
92
85
|
end
|
93
86
|
|
94
87
|
it 'registers the user' do
|
@@ -100,7 +93,7 @@ describe VMC::Start::Register do
|
|
100
93
|
let(:login) { true }
|
101
94
|
|
102
95
|
it 'logs in' do
|
103
|
-
any_instance_of
|
96
|
+
any_instance_of(described_class) do |register|
|
104
97
|
mock(register).invoke(:login, :username => email, :password => password)
|
105
98
|
end
|
106
99
|
subject
|
@@ -109,7 +102,7 @@ describe VMC::Start::Register do
|
|
109
102
|
|
110
103
|
context 'and the login flag is false' do
|
111
104
|
it "doesn't log in" do
|
112
|
-
any_instance_of
|
105
|
+
any_instance_of(described_class) do |register|
|
113
106
|
dont_allow(register).invoke(:login, :username => email, :password => password)
|
114
107
|
end
|
115
108
|
subject
|
@@ -125,7 +118,7 @@ describe VMC::Start::Register do
|
|
125
118
|
|
126
119
|
it 'prints out the password score' do
|
127
120
|
subject
|
128
|
-
expect(
|
121
|
+
expect(stderr.string).to include "Your password strength is: weak"
|
129
122
|
end
|
130
123
|
|
131
124
|
it "doesn't register" do
|
@@ -134,11 +127,22 @@ describe VMC::Start::Register do
|
|
134
127
|
end
|
135
128
|
|
136
129
|
it "doesn't log in" do
|
137
|
-
any_instance_of
|
130
|
+
any_instance_of(described_class) do |register|
|
138
131
|
dont_allow(register).invoke(:login, :username => email, :password => password)
|
139
132
|
end
|
140
133
|
subject
|
141
134
|
end
|
142
135
|
end
|
136
|
+
|
137
|
+
context 'when arguments are not passed in the command line' do
|
138
|
+
subject { vmc %W[register --no-force --no-login] }
|
139
|
+
|
140
|
+
it 'asks for the email, password and confirm password' do
|
141
|
+
mock_ask("Email") { email }
|
142
|
+
mock_ask("Password", anything) { password }
|
143
|
+
mock_ask("Confirm Password", anything) { verify_password }
|
144
|
+
subject
|
145
|
+
end
|
146
|
+
end
|
143
147
|
end
|
144
148
|
end
|