cf 1.1.3.rc1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
@@ -1,105 +1,100 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
|
19
|
-
end
|
20
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Spaces do
|
6
|
+
let(:full) { false }
|
7
|
+
let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
|
8
|
+
let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
|
9
|
+
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)) }
|
10
|
+
let(:spaces) { [space_1, space_2, space_3] }
|
11
|
+
let(:organization) { fake(:organization, :spaces => spaces, :name => "foo") }
|
12
|
+
let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
stub_client_and_precondition
|
16
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
17
|
+
end
|
21
18
|
|
22
|
-
|
23
|
-
|
19
|
+
describe "metadata" do
|
20
|
+
let(:command) { Mothership.commands[:spaces] }
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
describe "command" do
|
23
|
+
subject { command }
|
24
|
+
its(:description) { should eq "List spaces in an organization" }
|
25
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
26
|
+
end
|
30
27
|
|
31
|
-
|
28
|
+
include_examples "inputs must have descriptions"
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
describe "arguments" do
|
31
|
+
subject { command.arguments }
|
32
|
+
it "has the correct argument order" do
|
33
|
+
should eq([{:type => :optional, :value => nil, :name => :organization}])
|
34
|
+
end
|
35
|
+
end
|
37
36
|
end
|
38
|
-
end
|
39
|
-
end
|
40
37
|
|
41
|
-
|
38
|
+
subject { cf %W[spaces --#{bool_flag(:full)} --no-quiet] }
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
it "outputs that it is getting spaces" do
|
41
|
+
subject
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
stdout.rewind
|
44
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
45
|
+
expect(stdout.readline).to eq "\n"
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
48
|
+
context "when there are no spaces" do
|
49
|
+
let(:spaces) { [] }
|
53
50
|
|
54
|
-
|
55
|
-
|
51
|
+
context "and the full flag is given" do
|
52
|
+
let(:full) { true }
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
it "displays yaml-style output with all space details" do
|
55
|
+
CF::Space::Spaces.any_instance.should_not_receive(:invoke)
|
56
|
+
subject
|
57
|
+
end
|
60
58
|
end
|
61
|
-
subject
|
62
|
-
end
|
63
|
-
end
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
context "and the full flag is not given (default is false)" do
|
61
|
+
it "should show only the progress" do
|
62
|
+
subject
|
68
63
|
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
stdout.rewind
|
65
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
66
|
+
expect(stdout).to be_eof
|
67
|
+
end
|
68
|
+
end
|
72
69
|
end
|
73
|
-
end
|
74
|
-
end
|
75
70
|
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
context "when there are spaces" do
|
72
|
+
context "and the full flag is given" do
|
73
|
+
let(:full) { true }
|
79
74
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
it "displays yaml-style output with all space details" do
|
76
|
+
CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_2, :full => true)
|
77
|
+
CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_1, :full => true)
|
78
|
+
CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_3, :full => true)
|
79
|
+
subject
|
80
|
+
end
|
85
81
|
end
|
86
|
-
subject
|
87
|
-
end
|
88
|
-
end
|
89
82
|
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
context "and the full flag is not given (default is false)" do
|
84
|
+
it "displays tabular output with names, spaces and domains" do
|
85
|
+
subject
|
93
86
|
|
94
|
-
|
95
|
-
|
96
|
-
|
87
|
+
stdout.rewind
|
88
|
+
stdout.readline
|
89
|
+
stdout.readline
|
97
90
|
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
expect(stdout.readline).to match /name\s+apps\s+services/
|
92
|
+
spaces.sort_by(&:name).each do |space|
|
93
|
+
expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
|
94
|
+
end
|
95
|
+
expect(stdout).to be_eof
|
96
|
+
end
|
101
97
|
end
|
102
|
-
expect(stdout).to be_eof
|
103
98
|
end
|
104
99
|
end
|
105
100
|
end
|
@@ -1,60 +1,57 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Switch do
|
6
|
+
let(:space_to_switch_to) { spaces.last }
|
7
|
+
let(:spaces) { fake_list(:space, 3) }
|
8
|
+
let(:organization) { fake(:organization, :spaces => spaces) }
|
9
|
+
let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
CF::Space::Base.any_instance.stub(:client) { client }
|
13
|
+
CF::Space::Base.any_instance.stub(:precondition)
|
14
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
15
|
+
end
|
19
16
|
|
20
|
-
|
21
|
-
|
17
|
+
describe "metadata" do
|
18
|
+
let(:command) { Mothership.commands[:switch_space] }
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
describe "command" do
|
21
|
+
subject { command }
|
22
|
+
its(:description) { should eq "Switch to a space" }
|
23
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
24
|
+
end
|
28
25
|
|
29
|
-
|
26
|
+
include_examples "inputs must have descriptions"
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
describe "arguments" do
|
29
|
+
subject { command.arguments }
|
30
|
+
it "has the correct argument order" do
|
31
|
+
should eq([{:type => :normal, :value => nil, :name => :name}])
|
32
|
+
end
|
33
|
+
end
|
35
34
|
end
|
36
|
-
end
|
37
|
-
end
|
38
35
|
|
39
|
-
|
36
|
+
subject { cf %W[--no-quiet switch-space #{space_to_switch_to.name} --no-color] }
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
38
|
+
context "when the space exists" do
|
39
|
+
before do
|
40
|
+
Mothership.any_instance.should_receive(:invoke).with(:target, {:space => space_to_switch_to})
|
41
|
+
end
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
it "switches to that space" do
|
44
|
+
subject
|
45
|
+
end
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
48
|
+
context "when the space does not exist" do
|
49
|
+
let(:space_to_switch_to) { fake(:space, :name => "unique-name") }
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
it_behaves_like "an error that gets passed through",
|
52
|
+
:with_exception => CF::UserError,
|
53
|
+
:with_message => "The space unique-name does not exist, please create the space first."
|
54
|
+
end
|
55
|
+
end
|
59
56
|
end
|
60
57
|
end
|
@@ -16,9 +16,7 @@ describe CF::Start::Info do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
before do
|
19
|
-
|
20
|
-
stub(cli).client { client }
|
21
|
-
end
|
19
|
+
described_class.any_instance.stub(:client).and_return(client)
|
22
20
|
end
|
23
21
|
|
24
22
|
describe 'metadata' do
|
@@ -50,7 +48,7 @@ describe CF::Start::Info do
|
|
50
48
|
|
51
49
|
context 'when given no flags' do
|
52
50
|
it "displays target information" do
|
53
|
-
|
51
|
+
client.should_receive(:info).and_return(target_info)
|
54
52
|
|
55
53
|
subject
|
56
54
|
|
@@ -67,7 +65,7 @@ describe CF::Start::Info do
|
|
67
65
|
let(:services) { true }
|
68
66
|
|
69
67
|
it 'does not grab /info' do
|
70
|
-
|
68
|
+
client.should_not_receive(:info)
|
71
69
|
subject
|
72
70
|
end
|
73
71
|
|
@@ -89,7 +87,7 @@ describe CF::Start::Info do
|
|
89
87
|
let(:all) { true }
|
90
88
|
|
91
89
|
it 'runs as --services' do
|
92
|
-
|
90
|
+
client.should_receive(:info).and_return(target_info)
|
93
91
|
|
94
92
|
subject
|
95
93
|
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe CF::Start::Login do
|
4
4
|
let(:client) { fake_client }
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe "metadata" do
|
7
7
|
before do
|
8
8
|
stub_client_and_precondition
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:command) { Mothership.commands[:login] }
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe "command" do
|
14
14
|
subject { command }
|
15
15
|
its(:description) { should eq "Authenticate with the target" }
|
16
16
|
specify { expect(Mothership::Help.group(:start)).to include(subject) }
|
17
17
|
end
|
18
18
|
|
19
|
-
include_examples
|
19
|
+
include_examples "inputs must have descriptions"
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe "flags" do
|
22
22
|
subject { command.flags }
|
23
23
|
|
24
24
|
its(["-o"]) { should eq :organization }
|
@@ -27,9 +27,9 @@ describe CF::Start::Login do
|
|
27
27
|
its(["-s"]) { should eq :space }
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
30
|
+
describe "arguments" do
|
31
31
|
subject(:arguments) { command.arguments }
|
32
|
-
it
|
32
|
+
it "have the correct commands" do
|
33
33
|
expect(arguments).to eq [{:type => :optional, :value => :email, :name => :username}]
|
34
34
|
end
|
35
35
|
end
|
@@ -44,26 +44,25 @@ describe CF::Start::Login do
|
|
44
44
|
|
45
45
|
let(:auth_token) { CFoundry::AuthToken.new("bearer some-new-access-token", "some-new-refresh-token") }
|
46
46
|
let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
|
47
|
-
let(:tokens_file_path) {
|
47
|
+
let(:tokens_file_path) { "~/.cf/tokens.yml" }
|
48
48
|
|
49
49
|
before do
|
50
|
-
stub(
|
51
|
-
stub(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
50
|
+
client.stub(:login).with("my-username", "my-password") { auth_token }
|
51
|
+
client.stub(:login_prompts).and_return(
|
52
|
+
{
|
53
|
+
:username => ["text", "Username"],
|
54
|
+
:password => ["password", "8-digit PIN"]
|
55
|
+
})
|
57
56
|
|
58
57
|
stub_ask("Username", {}) { "my-username" }
|
59
58
|
stub_ask("8-digit PIN", {:echo => "*", :forget => true}) { "my-password" }
|
60
|
-
any_instance_of(CF::Populators::Target, :populate_and_save! => true)
|
61
59
|
end
|
62
60
|
|
63
61
|
subject { cf ["login"] }
|
64
62
|
|
65
63
|
context "when there is a target" do
|
66
64
|
before do
|
65
|
+
CF::Populators::Target.any_instance.stub(:populate_and_save!)
|
67
66
|
stub_precondition
|
68
67
|
end
|
69
68
|
|
@@ -75,13 +74,13 @@ describe CF::Start::Login do
|
|
75
74
|
end
|
76
75
|
|
77
76
|
it "calls use a PopulateTarget to ensure that an organization and space is set" do
|
78
|
-
|
77
|
+
CF::Populators::Target.should_receive(:new) { double(:target, :populate_and_save! => true) }
|
79
78
|
subject
|
80
79
|
end
|
81
80
|
|
82
81
|
context "when the user logs in with invalid credentials" do
|
83
82
|
before do
|
84
|
-
|
83
|
+
client.should_receive(:login).with("my-username", "my-password").and_raise(CFoundry::Denied)
|
85
84
|
end
|
86
85
|
|
87
86
|
it "informs the user gracefully" do
|
@@ -92,9 +91,8 @@ describe CF::Start::Login do
|
|
92
91
|
end
|
93
92
|
|
94
93
|
context "when there is no target" do
|
95
|
-
let(:client) { nil }
|
96
|
-
|
97
94
|
it "tells the user to select a target" do
|
95
|
+
client.stub(:target) { nil }
|
98
96
|
subject
|
99
97
|
expect(error_output).to say("Please select a target with 'cf target'.")
|
100
98
|
end
|
@@ -1,50 +1,49 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module CF
|
4
|
+
module Start
|
5
|
+
describe Logout do
|
6
|
+
let(:client) { fake_client }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
8
|
+
before do
|
9
|
+
described_class.any_instance.stub(:client) { client }
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
describe "metadata" do
|
13
|
+
let(:command) { Mothership.commands[:logout] }
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
describe "command" do
|
16
|
+
subject { command }
|
17
|
+
its(:description) { should eq "Log out from the target" }
|
18
|
+
it { expect(Mothership::Help.group(:start)).to include(subject) }
|
19
|
+
end
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
describe "running the command" do
|
23
|
+
subject { cf ["logout"] }
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
context "when there is a target" do
|
26
|
+
let(:info) { {client.target => "x", "abc" => "x"} }
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
before do
|
29
|
+
CF::CLI.any_instance.stub(:targets_info) { info }
|
30
|
+
CF::CLI.any_instance.stub(:client_target) { client.target }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "removes the target info from the tokens file" do
|
34
|
+
expect {
|
35
|
+
subject
|
36
|
+
}.to change { info }.to("abc" => "x")
|
37
|
+
end
|
32
38
|
end
|
33
|
-
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
context "when there is no target" do
|
41
|
+
let(:client) { nil }
|
42
|
+
it_behaves_like "an error that gets passed through",
|
43
|
+
:with_exception => CF::UserError,
|
44
|
+
:with_message => "Please select a target with 'cf target'."
|
45
|
+
end
|
39
46
|
end
|
40
47
|
end
|
41
|
-
|
42
|
-
context "when there is no target" do
|
43
|
-
let(:client) { nil }
|
44
|
-
it_behaves_like "an error that gets passed through",
|
45
|
-
:with_exception => CF::UserError,
|
46
|
-
:with_message => "Please select a target with 'cf target'."
|
47
|
-
end
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|