vmc 0.5.0.beta.5 → 0.5.0.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vmc/cli.rb +8 -0
- data/lib/vmc/cli/start/register.rb +14 -5
- data/lib/vmc/cli/user/passwd.rb +16 -7
- data/lib/vmc/version.rb +1 -1
- data/spec/features/new_user_flow_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/support/common_input_examples.rb +14 -0
- data/spec/support/feature_helpers.rb +2 -6
- data/spec/vmc/cli/app/delete_spec.rb +1 -12
- data/spec/vmc/cli/app/push_spec.rb +1 -10
- data/spec/vmc/cli/app/rename_spec.rb +1 -10
- data/spec/vmc/cli/organization/orgs_spec.rb +1 -10
- data/spec/vmc/cli/route/delete_route_spec.rb +2 -0
- data/spec/vmc/cli/service/bind_spec.rb +1 -10
- data/spec/vmc/cli/service/delete_spec.rb +1 -11
- data/spec/vmc/cli/service/rename_spec.rb +1 -10
- data/spec/vmc/cli/service/service_spec.rb +1 -10
- data/spec/vmc/cli/service/unbind_spec.rb +1 -10
- data/spec/vmc/cli/space/rename_spec.rb +1 -10
- data/spec/vmc/cli/space/spaces_spec.rb +1 -10
- data/spec/vmc/cli/start/info_spec.rb +1 -10
- data/spec/vmc/cli/start/login_spec.rb +1 -10
- data/spec/vmc/cli/start/register_spec.rb +144 -0
- data/spec/vmc/cli/user/passwd_spec.rb +105 -0
- data/spec/vmc/cli_spec.rb +24 -2
- metadata +13 -7
data/lib/vmc/cli.rb
CHANGED
@@ -38,6 +38,9 @@ module VMC
|
|
38
38
|
option :force, :desc => "Skip interaction when possible", :alias => "-f",
|
39
39
|
:type => :boolean, :default => proc { input[:script] }
|
40
40
|
|
41
|
+
option :debug, :desc => "Print full stack trace (instead of crash log)",
|
42
|
+
:type => :boolean, :default => false
|
43
|
+
|
41
44
|
option :quiet, :desc => "Simplify output format", :alias => "-q",
|
42
45
|
:type => :boolean, :default => proc { input[:script] }
|
43
46
|
|
@@ -137,6 +140,7 @@ module VMC
|
|
137
140
|
msg << ": #{e}" unless e.to_s.empty?
|
138
141
|
msg << "\nFor more information, see #{VMC::CRASH_FILE}"
|
139
142
|
err msg
|
143
|
+
raise if debug?
|
140
144
|
end
|
141
145
|
|
142
146
|
def log_error(e)
|
@@ -173,6 +177,10 @@ module VMC
|
|
173
177
|
input[:force]
|
174
178
|
end
|
175
179
|
|
180
|
+
def debug?
|
181
|
+
!!input[:debug]
|
182
|
+
end
|
183
|
+
|
176
184
|
def color_enabled?
|
177
185
|
input[:color]
|
178
186
|
end
|
@@ -18,12 +18,21 @@ module VMC::Start
|
|
18
18
|
fail "Passwords do not match."
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
pw_strength = client.base.uaa.password_score(password)
|
22
|
+
msg = "Your password strength is: #{pw_strength}"
|
23
|
+
|
24
|
+
if pw_strength == :weak
|
25
|
+
fail msg
|
26
|
+
else
|
27
|
+
line msg
|
28
|
+
|
29
|
+
with_progress("Creating user") do
|
30
|
+
client.register(email, password)
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
33
|
+
if input[:login]
|
34
|
+
invoke :login, :username => email, :password => password
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
data/lib/vmc/cli/user/passwd.rb
CHANGED
@@ -23,15 +23,24 @@ module VMC::User
|
|
23
23
|
verify = input[:verify]
|
24
24
|
|
25
25
|
if new_password != verify
|
26
|
-
fail "Passwords
|
26
|
+
fail "Passwords do not match."
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
pw_strength = client.base.uaa.password_score(new_password)
|
30
|
+
msg = "Your password strength is: #{pw_strength}"
|
31
|
+
|
32
|
+
if pw_strength == :weak
|
33
|
+
fail msg
|
34
|
+
else
|
35
|
+
line msg
|
36
|
+
|
37
|
+
with_progress("Changing password") do
|
38
|
+
if v2?
|
39
|
+
user.change_password!(new_password, password)
|
40
|
+
else
|
41
|
+
user.password = new_password
|
42
|
+
user.update!
|
43
|
+
end
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
data/lib/vmc/version.rb
CHANGED
@@ -6,7 +6,7 @@ if ENV['VMC_TEST_USER'] && ENV['VMC_TEST_PASSWORD'] && ENV['VMC_TEST_TARGET']
|
|
6
6
|
let(:username) { ENV['VMC_TEST_USER'] }
|
7
7
|
let(:password) { ENV['VMC_TEST_PASSWORD'] }
|
8
8
|
let(:output) { StringIO.new }
|
9
|
-
let(:out) { output.string.
|
9
|
+
let(:out) { output.string.strip_progress_dots }
|
10
10
|
|
11
11
|
let(:app) {
|
12
12
|
fuzz =
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
shared_examples_for 'inputs must have descriptions' do
|
2
|
+
describe 'inputs' do
|
3
|
+
subject { command.inputs }
|
4
|
+
|
5
|
+
it "is not missing any descriptions" do
|
6
|
+
subject.each do |_, attrs|
|
7
|
+
next if attrs[:hidden]
|
8
|
+
|
9
|
+
expect(attrs[:description]).to be
|
10
|
+
expect(attrs[:description].strip).to_not be_empty
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
def vmc_ok(argv)
|
2
2
|
with_output_to do |out|
|
3
3
|
code = VMC::CLI.start(argv + ["--no-script"])
|
4
|
-
yield
|
4
|
+
yield out.string.strip_progress_dots if block_given?
|
5
5
|
expect(code).to eq 0
|
6
6
|
end
|
7
7
|
end
|
@@ -9,11 +9,7 @@ end
|
|
9
9
|
def vmc_fail(argv)
|
10
10
|
with_output_to do |out|
|
11
11
|
code = VMC::CLI.start(argv + ["--no-script"])
|
12
|
-
yield
|
12
|
+
yield out.string.strip_progress_dots if block_given?
|
13
13
|
expect(code).to eq 1
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
def strip_progress_dots(str)
|
18
|
-
str.gsub(/\. \x08([\x08\. ]+)/, "... ")
|
19
|
-
end
|
@@ -27,18 +27,7 @@ describe VMC::App::Delete do
|
|
27
27
|
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
subject { command.inputs }
|
32
|
-
|
33
|
-
it "is not missing any descriptions" do
|
34
|
-
subject.each do |input, attrs|
|
35
|
-
next if attrs[:hidden]
|
36
|
-
|
37
|
-
expect(attrs[:description]).to be
|
38
|
-
expect(attrs[:description].strip).to_not be_empty
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
30
|
+
include_examples 'inputs must have descriptions'
|
42
31
|
|
43
32
|
describe 'arguments' do
|
44
33
|
subject { command.arguments }
|
@@ -25,16 +25,7 @@ describe VMC::App::Push do
|
|
25
25
|
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
subject { command.inputs }
|
30
|
-
|
31
|
-
it "is not missing any descriptions" do
|
32
|
-
subject.each do |input, attrs|
|
33
|
-
expect(attrs[:description]).to be
|
34
|
-
expect(attrs[:description].strip).to_not be_empty
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
28
|
+
include_examples 'inputs must have descriptions'
|
38
29
|
|
39
30
|
describe 'arguments' do
|
40
31
|
subject { command.arguments }
|
@@ -27,16 +27,7 @@ describe VMC::App::Rename do
|
|
27
27
|
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
subject { command.inputs }
|
32
|
-
|
33
|
-
it "is not missing any descriptions" do
|
34
|
-
subject.each do |input, attrs|
|
35
|
-
expect(attrs[:description]).to be
|
36
|
-
expect(attrs[:description].strip).to_not be_empty
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
30
|
+
include_examples 'inputs must have descriptions'
|
40
31
|
|
41
32
|
describe 'arguments' do
|
42
33
|
subject { command.arguments }
|
@@ -34,16 +34,7 @@ describe VMC::Organization::Orgs do
|
|
34
34
|
it { expect(Mothership::Help.group(:organizations)).to include(subject) }
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
subject { command.inputs }
|
39
|
-
|
40
|
-
it "is not missing any descriptions" do
|
41
|
-
subject.each do |_, attrs|
|
42
|
-
expect(attrs[:description]).to be
|
43
|
-
expect(attrs[:description].strip).to_not be_empty
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
37
|
+
include_examples 'inputs must have descriptions'
|
47
38
|
|
48
39
|
describe 'arguments' do
|
49
40
|
subject { command.arguments }
|
@@ -25,6 +25,8 @@ describe VMC::Route::Delete do
|
|
25
25
|
it { expect(Mothership::Help.group(:routes)).to include(subject) }
|
26
26
|
end
|
27
27
|
|
28
|
+
include_examples 'inputs must have descriptions'
|
29
|
+
|
28
30
|
describe 'inputs' do
|
29
31
|
subject { command.inputs }
|
30
32
|
it { expect(subject[:route][:description]).to eq "Route to delete" }
|
@@ -10,16 +10,7 @@ describe VMC::Service::Bind do
|
|
10
10
|
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |_, attrs|
|
18
|
-
expect(attrs[:description]).to be
|
19
|
-
expect(attrs[:description].strip).to_not be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
23
14
|
|
24
15
|
describe 'arguments' do
|
25
16
|
subject { command.arguments }
|
@@ -10,17 +10,7 @@ describe VMC::Service::Delete do
|
|
10
10
|
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |_, attrs|
|
18
|
-
next if attrs[:hidden]
|
19
|
-
expect(attrs[:description]).to be
|
20
|
-
expect(attrs[:description].strip).to_not be_empty
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
24
14
|
|
25
15
|
describe 'arguments' do
|
26
16
|
subject { command.arguments }
|
@@ -27,16 +27,7 @@ describe VMC::Service::Rename do
|
|
27
27
|
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
subject { command.inputs }
|
32
|
-
|
33
|
-
it "is not missing any descriptions" do
|
34
|
-
subject.each do |input, attrs|
|
35
|
-
expect(attrs[:description]).to be
|
36
|
-
expect(attrs[:description].strip).to_not be_empty
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
30
|
+
include_examples 'inputs must have descriptions'
|
40
31
|
|
41
32
|
describe 'arguments' do
|
42
33
|
subject { command.arguments }
|
@@ -10,16 +10,7 @@ describe VMC::Service::Service do
|
|
10
10
|
it { expect(Mothership::Help.group(:services)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |_, attrs|
|
18
|
-
expect(attrs[:description]).to be
|
19
|
-
expect(attrs[:description].strip).to_not be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
23
14
|
|
24
15
|
describe 'arguments' do
|
25
16
|
subject { command.arguments }
|
@@ -10,16 +10,7 @@ describe VMC::Service::Unbind do
|
|
10
10
|
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |input, attrs|
|
18
|
-
expect(attrs[:description]).to be
|
19
|
-
expect(attrs[:description].strip).to_not be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
23
14
|
|
24
15
|
describe 'arguments' do
|
25
16
|
subject { command.arguments }
|
@@ -28,16 +28,7 @@ describe VMC::Space::Rename do
|
|
28
28
|
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
subject { command.inputs }
|
33
|
-
|
34
|
-
it "is not missing any descriptions" do
|
35
|
-
subject.each do |input, attrs|
|
36
|
-
expect(attrs[:description]).to be
|
37
|
-
expect(attrs[:description].strip).to_not be_empty
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
31
|
+
include_examples 'inputs must have descriptions'
|
41
32
|
|
42
33
|
describe 'arguments' do
|
43
34
|
subject { command.arguments }
|
@@ -35,16 +35,7 @@ describe VMC::Space::Spaces do
|
|
35
35
|
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
subject { command.inputs }
|
40
|
-
|
41
|
-
it "is not missing any descriptions" do
|
42
|
-
subject.each do |_, attrs|
|
43
|
-
expect(attrs[:description]).to be
|
44
|
-
expect(attrs[:description].strip).to_not be_empty
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
38
|
+
include_examples 'inputs must have descriptions'
|
48
39
|
|
49
40
|
describe 'arguments' do
|
50
41
|
subject { command.arguments }
|
@@ -10,16 +10,7 @@ describe VMC::Start::Info do
|
|
10
10
|
it { expect(Mothership::Help.group(:start)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |_, attrs|
|
18
|
-
expect(attrs[:description]).to be
|
19
|
-
expect(attrs[:description].strip).to_not be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
23
14
|
|
24
15
|
describe 'flags' do
|
25
16
|
subject { command.flags }
|
@@ -10,16 +10,7 @@ describe VMC::Start::Login do
|
|
10
10
|
it { expect(Mothership::Help.group(:start)).to include(subject) }
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
subject { command.inputs }
|
15
|
-
|
16
|
-
it "is not missing any descriptions" do
|
17
|
-
subject.each do |_, attrs|
|
18
|
-
expect(attrs[:description]).to be
|
19
|
-
expect(attrs[:description].strip).to_not be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
13
|
+
include_examples 'inputs must have descriptions'
|
23
14
|
|
24
15
|
describe 'flags' do
|
25
16
|
subject { command.flags }
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::Start::Register do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:register] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Create a user and log in" }
|
10
|
+
it { expect(Mothership::Help.group(:start)).to include(subject) }
|
11
|
+
end
|
12
|
+
|
13
|
+
include_examples 'inputs must have descriptions'
|
14
|
+
|
15
|
+
describe 'arguments' do
|
16
|
+
subject { command.arguments }
|
17
|
+
it 'have the correct commands' do
|
18
|
+
should eq [
|
19
|
+
{:type => :optional, :value => nil, :name => :email}
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#register' do
|
26
|
+
let(:client) { FactoryGirl.build(:client) }
|
27
|
+
let(:output) { StringIO.new }
|
28
|
+
let(:out) { output.string }
|
29
|
+
let(:email) { "a@b.com" }
|
30
|
+
let(:password) { "password" }
|
31
|
+
let(:verify_password) { password }
|
32
|
+
let(:force) { false }
|
33
|
+
let(:login) { false }
|
34
|
+
let(:score) { :strong }
|
35
|
+
|
36
|
+
before do
|
37
|
+
stub(VMC::CLI).exit { |code| code }
|
38
|
+
any_instance_of(VMC::CLI) do |cli|
|
39
|
+
stub(cli).client { client }
|
40
|
+
stub(cli).precondition { nil }
|
41
|
+
end
|
42
|
+
stub(client).register
|
43
|
+
stub(client).base.stub!.uaa.stub!.password_score(password) { score }
|
44
|
+
end
|
45
|
+
|
46
|
+
subject do
|
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
|
51
|
+
|
52
|
+
context 'when the passwords dont match' do
|
53
|
+
let(:verify_password) { "other_password" }
|
54
|
+
|
55
|
+
it { should eq 1 }
|
56
|
+
|
57
|
+
it 'fails' do
|
58
|
+
subject
|
59
|
+
expect(out).to include "Passwords do not match."
|
60
|
+
end
|
61
|
+
|
62
|
+
it "doesn't print out the score" do
|
63
|
+
subject
|
64
|
+
expect(out).not_to include "strength"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "doesn't log in or register" do
|
68
|
+
dont_allow(client).register
|
69
|
+
any_instance_of VMC::Start::Register do |register|
|
70
|
+
dont_allow(register).invoke
|
71
|
+
end
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'and the force flag is passed' do
|
76
|
+
let(:force) { true }
|
77
|
+
|
78
|
+
it "doesn't verify the password" do
|
79
|
+
mock(client).register(email, password)
|
80
|
+
subject
|
81
|
+
expect(out).not_to include "Passwords do not match."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when the password is good or strong' do
|
87
|
+
it { should eq 0 }
|
88
|
+
|
89
|
+
it 'prints out the password score' do
|
90
|
+
subject
|
91
|
+
expect(out).to include "Your password strength is: strong"
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'registers the user' do
|
95
|
+
mock(client).register(email, password)
|
96
|
+
subject
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'and the login flag is true' do
|
100
|
+
let(:login) { true }
|
101
|
+
|
102
|
+
it 'logs in' do
|
103
|
+
any_instance_of VMC::Start::Register do |register|
|
104
|
+
mock(register).invoke(:login, :username => email, :password => password)
|
105
|
+
end
|
106
|
+
subject
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'and the login flag is false' do
|
111
|
+
it "doesn't log in" do
|
112
|
+
any_instance_of VMC::Start::Register do |register|
|
113
|
+
dont_allow(register).invoke(:login, :username => email, :password => password)
|
114
|
+
end
|
115
|
+
subject
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when the password is weak' do
|
121
|
+
let(:score) { :weak }
|
122
|
+
let(:login) { true }
|
123
|
+
|
124
|
+
it { should eq 1 }
|
125
|
+
|
126
|
+
it 'prints out the password score' do
|
127
|
+
subject
|
128
|
+
expect(out).to include "Your password strength is: weak"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "doesn't register" do
|
132
|
+
dont_allow(client).register(email, password)
|
133
|
+
subject
|
134
|
+
end
|
135
|
+
|
136
|
+
it "doesn't log in" do
|
137
|
+
any_instance_of VMC::Start::Register do |register|
|
138
|
+
dont_allow(register).invoke(:login, :username => email, :password => password)
|
139
|
+
end
|
140
|
+
subject
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::User::Passwd do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:passwd] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Update a user's password" }
|
10
|
+
it { expect(Mothership::Help.group(:admin, :user)).to include(subject) }
|
11
|
+
end
|
12
|
+
|
13
|
+
include_examples 'inputs must have descriptions'
|
14
|
+
|
15
|
+
describe 'arguments' do
|
16
|
+
subject { command.arguments }
|
17
|
+
it 'have the correct commands (with inconsistent user instead of email)' do
|
18
|
+
should eq [{:type => :optional, :value => nil, :name => :user}]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#passwd' do
|
24
|
+
let(:client) { FactoryGirl.build(:client) }
|
25
|
+
let(:output) { StringIO.new }
|
26
|
+
let(:out) { output.string }
|
27
|
+
let(:old_password) { "old" }
|
28
|
+
let(:new_password) { "password" }
|
29
|
+
let(:verify_password) { new_password }
|
30
|
+
let(:score) { :strong }
|
31
|
+
let(:user) { FactoryGirl.build(:user) }
|
32
|
+
|
33
|
+
before do
|
34
|
+
stub(VMC::CLI).exit { |code| code }
|
35
|
+
any_instance_of(VMC::CLI) do |cli|
|
36
|
+
stub(cli).client { client }
|
37
|
+
stub(cli).precondition { nil }
|
38
|
+
end
|
39
|
+
stub(client).current_user { user }
|
40
|
+
stub(client).register
|
41
|
+
stub(client).base.stub!.uaa.stub!.password_score(new_password) { score }
|
42
|
+
end
|
43
|
+
|
44
|
+
subject do
|
45
|
+
with_output_to output do
|
46
|
+
VMC::CLI.start %W(passwd --password #{old_password} --new-password #{new_password} --verify #{verify_password} --force --debug)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when the passwords dont match' do
|
51
|
+
let(:verify_password) { "other_password" }
|
52
|
+
|
53
|
+
it { should eq 1 }
|
54
|
+
|
55
|
+
it 'fails' do
|
56
|
+
subject
|
57
|
+
expect(out).to include "Passwords do not match."
|
58
|
+
end
|
59
|
+
|
60
|
+
it "doesn't print out the score" do
|
61
|
+
subject
|
62
|
+
expect(out).not_to include "strength"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "doesn't log in or register" do
|
66
|
+
dont_allow(user).change_password!
|
67
|
+
subject
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when the password is good or strong' do
|
72
|
+
before do
|
73
|
+
stub(user).change_password!
|
74
|
+
end
|
75
|
+
|
76
|
+
it { should eq 0 }
|
77
|
+
|
78
|
+
it 'prints out the password score' do
|
79
|
+
subject
|
80
|
+
expect(out).to include "Your password strength is: strong"
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'changes the password' do
|
84
|
+
mock(user).change_password!(new_password, old_password)
|
85
|
+
subject
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when the password is weak' do
|
90
|
+
let(:score) { :weak }
|
91
|
+
|
92
|
+
it { should eq 1 }
|
93
|
+
|
94
|
+
it 'prints out the password score' do
|
95
|
+
subject
|
96
|
+
expect(out).to include "Your password strength is: weak"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "doesn't change the password" do
|
100
|
+
dont_allow(user).change_password!
|
101
|
+
subject
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/spec/vmc/cli_spec.rb
CHANGED
@@ -4,9 +4,13 @@ describe VMC::CLI do
|
|
4
4
|
let(:cmd) { Class.new(VMC::CLI).new }
|
5
5
|
|
6
6
|
describe '#execute' do
|
7
|
+
let(:inputs) { {} }
|
8
|
+
|
7
9
|
subject do
|
8
|
-
|
9
|
-
|
10
|
+
with_output_to do
|
11
|
+
stub(cmd).input { inputs }
|
12
|
+
cmd.execute(nil, [])
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
it 'wraps Timeout::Error with a more friendly message' do
|
@@ -15,6 +19,24 @@ describe VMC::CLI do
|
|
15
19
|
mock(cmd).err "GET /foo timed out"
|
16
20
|
subject
|
17
21
|
end
|
22
|
+
|
23
|
+
context "when the debug flag is on" do
|
24
|
+
let(:inputs) { {:debug => true} }
|
25
|
+
|
26
|
+
it 'reraises' do
|
27
|
+
stub(cmd).precondition { raise StandardError.new }
|
28
|
+
expect { subject }.to raise_error(StandardError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when the debug flag is off" do
|
33
|
+
it 'outputs the crash log message' do
|
34
|
+
stub(cmd).precondition { raise StandardError.new }
|
35
|
+
mock(cmd).err "StandardError: StandardError\nFor more information, see /Users/pivotal/workspace/vmc/vmc/spec/tmp/.vmc/crash"
|
36
|
+
|
37
|
+
expect { subject }.not_to raise_error(StandardError)
|
38
|
+
end
|
39
|
+
end
|
18
40
|
end
|
19
41
|
end
|
20
42
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -504813842
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.5.0.beta.
|
11
|
+
- 6
|
12
|
+
version: 0.5.0.beta.6
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Alex Suraci
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-12-
|
20
|
+
date: 2012-12-19 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: json_pure
|
@@ -73,12 +73,12 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
76
|
+
hash: 47
|
77
77
|
segments:
|
78
78
|
- 0
|
79
79
|
- 4
|
80
|
-
-
|
81
|
-
version: 0.4.
|
80
|
+
- 16
|
81
|
+
version: 0.4.16
|
82
82
|
type: :runtime
|
83
83
|
version_requirements: *id004
|
84
84
|
- !ruby/object:Gem::Dependency
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- spec/assets/hello-sinatra/main.rb
|
315
315
|
- spec/features/new_user_flow_spec.rb
|
316
316
|
- spec/spec_helper.rb
|
317
|
+
- spec/support/common_input_examples.rb
|
317
318
|
- spec/support/feature_helpers.rb
|
318
319
|
- spec/support/interact_helpers.rb
|
319
320
|
- spec/vmc/cli/app/delete_spec.rb
|
@@ -332,6 +333,8 @@ files:
|
|
332
333
|
- spec/vmc/cli/space/spaces_spec.rb
|
333
334
|
- spec/vmc/cli/start/info_spec.rb
|
334
335
|
- spec/vmc/cli/start/login_spec.rb
|
336
|
+
- spec/vmc/cli/start/register_spec.rb
|
337
|
+
- spec/vmc/cli/user/passwd_spec.rb
|
335
338
|
- spec/vmc/cli_spec.rb
|
336
339
|
- spec/vmc/detect_spec.rb
|
337
340
|
- bin/vmc
|
@@ -375,6 +378,7 @@ test_files:
|
|
375
378
|
- spec/assets/hello-sinatra/main.rb
|
376
379
|
- spec/features/new_user_flow_spec.rb
|
377
380
|
- spec/spec_helper.rb
|
381
|
+
- spec/support/common_input_examples.rb
|
378
382
|
- spec/support/feature_helpers.rb
|
379
383
|
- spec/support/interact_helpers.rb
|
380
384
|
- spec/vmc/cli/app/delete_spec.rb
|
@@ -393,5 +397,7 @@ test_files:
|
|
393
397
|
- spec/vmc/cli/space/spaces_spec.rb
|
394
398
|
- spec/vmc/cli/start/info_spec.rb
|
395
399
|
- spec/vmc/cli/start/login_spec.rb
|
400
|
+
- spec/vmc/cli/start/register_spec.rb
|
401
|
+
- spec/vmc/cli/user/passwd_spec.rb
|
396
402
|
- spec/vmc/cli_spec.rb
|
397
403
|
- spec/vmc/detect_spec.rb
|