cf 1.1.3.rc1 → 1.1.4
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/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,155 +1,153 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "webmock/rspec"
|
3
|
-
require "cf/cli/populators/organization"
|
4
|
-
|
5
|
-
describe CF::Populators::Organization do
|
6
|
-
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
7
|
-
|
8
|
-
describe "#populate_and_save!" do
|
9
|
-
let(:tokens_file_path) { CF::TOKENS_FILE }
|
10
|
-
let(:user) { stub! }
|
11
|
-
let(:organizations) do
|
12
|
-
[
|
13
|
-
fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
|
14
|
-
fake(:organization, :guid => "organization-id-2")
|
15
|
-
]
|
16
|
-
end
|
17
|
-
let(:organization) { organizations.first }
|
18
|
-
let(:client) { fake_client :organizations => organizations }
|
19
|
-
|
20
|
-
let(:input) { {:organization => organization} }
|
21
|
-
let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
|
22
|
-
let(:populator) { populator = CF::Populators::Organization.new(Mothership::Inputs.new(nil, nil, input)) }
|
23
|
-
|
24
|
-
before do
|
25
|
-
stub(client).current_user { user }
|
26
|
-
stub(client).organization { organization }
|
27
|
-
stub(client).current_organization { organization }
|
28
|
-
stub(client).target { 'https://api.some-domain.com' }
|
29
|
-
any_instance_of(described_class) do |instance|
|
30
|
-
stub(instance).client { client }
|
31
|
-
end
|
32
2
|
|
33
|
-
|
34
|
-
|
3
|
+
module CF
|
4
|
+
module Populators
|
5
|
+
describe Organization do
|
6
|
+
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
7
|
+
|
8
|
+
describe "#populate_and_save!" do
|
9
|
+
let(:tokens_file_path) { CF::TOKENS_FILE }
|
10
|
+
let(:user) { build(:user) }
|
11
|
+
let(:organizations) do
|
12
|
+
[
|
13
|
+
double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
|
14
|
+
double(:organization, :name => "Other Org", :guid => "organization-id-2")
|
15
|
+
]
|
16
|
+
end
|
17
|
+
let(:organization) { organizations.first }
|
18
|
+
let(:client) { fake_client :organizations => organizations }
|
35
19
|
|
36
|
-
|
37
|
-
|
38
|
-
|
20
|
+
let(:input) { {:organization => organization} }
|
21
|
+
let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
|
22
|
+
let(:populator) { populator = CF::Populators::Organization.new(Mothership::Inputs.new(nil, nil, input)) }
|
39
23
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
before do
|
25
|
+
client.stub(:current_user).and_return(user)
|
26
|
+
client.stub(:organization).and_return(organization)
|
27
|
+
client.stub(:current_organization).and_return(organization)
|
28
|
+
client.stub(:target).and_return('https://api.some-domain.com')
|
29
|
+
described_class.any_instance.stub(:client).and_return(client)
|
46
30
|
|
47
|
-
|
31
|
+
write_token_file({:organization => "organization-id-1"})
|
32
|
+
end
|
48
33
|
|
49
|
-
|
50
|
-
|
34
|
+
subject do
|
35
|
+
capture_output { populator.populate_and_save! }
|
36
|
+
end
|
51
37
|
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
it "updates the client with the new organization" do
|
39
|
+
write_token_file({:organization => "organization-id-2"})
|
40
|
+
described_class.any_instance.unstub(:client)
|
41
|
+
populator.client.current_organization.guid.should == "organization-id-2"
|
55
42
|
|
56
|
-
|
57
|
-
let(:input) { {:organization => organization} }
|
58
|
-
before { write_token_file({:organization => "organization-id-2"}) }
|
43
|
+
subject
|
59
44
|
|
60
|
-
|
61
|
-
|
62
|
-
end
|
45
|
+
populator.client.current_organization.guid.should == "organization-id-1"
|
46
|
+
end
|
63
47
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
48
|
+
it "returns the organization" do
|
49
|
+
subject.should == organization
|
50
|
+
end
|
68
51
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
52
|
+
context "with an organization in the input" do
|
53
|
+
let(:input) { {:organization => organization} }
|
54
|
+
before { write_token_file({:organization => "organization-id-2"}) }
|
73
55
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
56
|
+
it "uses that organization" do
|
57
|
+
subject.should == organization
|
58
|
+
end
|
78
59
|
|
79
|
-
|
80
|
-
|
60
|
+
it "should not reprompt for organization" do
|
61
|
+
dont_allow_ask("Organization", anything)
|
62
|
+
subject
|
63
|
+
end
|
81
64
|
|
82
|
-
|
83
|
-
|
84
|
-
|
65
|
+
it "sets the organization in the token file" do
|
66
|
+
subject
|
67
|
+
expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
|
68
|
+
end
|
85
69
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
70
|
+
it "prints out that it is switching to that organization" do
|
71
|
+
subject
|
72
|
+
expect(output).to say("Switching to organization #{organization.name}")
|
73
|
+
end
|
91
74
|
|
92
|
-
|
75
|
+
context "and a different organization and space in the token file" do
|
76
|
+
let(:input) { {:organization => organizations.last} }
|
93
77
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
78
|
+
before do
|
79
|
+
write_token_file({:organization => "organization-id-1", :space => "should-be-removed"})
|
80
|
+
end
|
98
81
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
82
|
+
it "removes the space from the token file" do
|
83
|
+
subject
|
84
|
+
refreshed_tokens = YAML.load_file(File.expand_path(tokens_file_path))
|
85
|
+
expect(refreshed_tokens["https://api.some-domain.com"][:space]).to be_nil
|
86
|
+
end
|
104
87
|
|
105
|
-
|
88
|
+
end
|
106
89
|
|
107
|
-
|
108
|
-
|
90
|
+
context "and the same organization and a space in the token file" do
|
91
|
+
before do
|
92
|
+
write_token_file({:organization => "organization-id-1", :space => "should-not-be-removed"})
|
93
|
+
end
|
109
94
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
95
|
+
it "does not remove the space from the token file" do
|
96
|
+
subject
|
97
|
+
expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "should-not-be-removed"
|
98
|
+
end
|
99
|
+
end
|
115
100
|
|
116
|
-
it "sets the organization in the token file" do
|
117
|
-
subject
|
118
|
-
expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
|
119
101
|
end
|
120
102
|
|
121
|
-
context "
|
122
|
-
|
103
|
+
context "without an organization in the input" do
|
104
|
+
let(:input) { {} }
|
123
105
|
|
124
|
-
|
125
|
-
|
126
|
-
|
106
|
+
context "with an organization in the config file" do
|
107
|
+
it "should not reprompt for organization" do
|
108
|
+
dont_allow_ask("Organization", anything)
|
109
|
+
subject
|
110
|
+
end
|
111
|
+
|
112
|
+
it "sets the organization in the token file" do
|
113
|
+
subject
|
114
|
+
expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
|
115
|
+
end
|
116
|
+
|
117
|
+
context "but that organization doesn't exist anymore (not valid)" do
|
118
|
+
before { organization.stub(:users).and_raise(CFoundry::APIError) }
|
119
|
+
|
120
|
+
it "asks the user for an organization" do
|
121
|
+
mock_ask("Organization", anything) { organization }
|
122
|
+
subject
|
123
|
+
end
|
124
|
+
end
|
127
125
|
end
|
128
|
-
end
|
129
|
-
end
|
130
126
|
|
131
|
-
|
132
|
-
|
127
|
+
context "without an organization in the config file" do
|
128
|
+
before { write_token_file({}) }
|
133
129
|
|
134
|
-
|
135
|
-
|
136
|
-
|
130
|
+
it "prompts for the organization" do
|
131
|
+
mock_ask("Organization", anything) { organization }
|
132
|
+
subject
|
137
133
|
|
138
|
-
|
139
|
-
|
134
|
+
expect(output).to say("Switching to organization #{organization.name}")
|
135
|
+
end
|
140
136
|
|
141
|
-
|
142
|
-
|
137
|
+
it "sets the organization in the token file" do
|
138
|
+
mock_ask("Organization", anything) { organization }
|
143
139
|
|
144
|
-
|
145
|
-
|
146
|
-
|
140
|
+
subject
|
141
|
+
expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
|
142
|
+
end
|
147
143
|
|
148
|
-
|
149
|
-
|
144
|
+
context "when the user has no organizations" do
|
145
|
+
let(:client) { fake_client :organizations => [] }
|
150
146
|
|
151
|
-
|
152
|
-
|
147
|
+
it "tells the user to create one by raising a UserFriendlyError" do
|
148
|
+
expect { subject }.to raise_error(CF::UserFriendlyError, /There are no organizations/)
|
149
|
+
end
|
150
|
+
end
|
153
151
|
end
|
154
152
|
end
|
155
153
|
end
|
@@ -1,142 +1,141 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "webmock/rspec"
|
3
|
-
require "cf/cli/populators/space"
|
4
|
-
|
5
|
-
describe CF::Populators::Space do
|
6
|
-
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
7
|
-
|
8
|
-
describe "#populate_and_save!" do
|
9
|
-
let(:tokens_file_path) { "~/.cf/tokens.yml" }
|
10
|
-
let(:spaces) {
|
11
|
-
[fake(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
|
12
|
-
fake(:space, :name => "Staging", :guid => "space-id-2")]
|
13
|
-
}
|
14
|
-
|
15
|
-
let(:user) { stub! }
|
16
|
-
let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
|
17
|
-
let(:space) { spaces.first }
|
18
|
-
let(:client) do
|
19
|
-
fake_client :organizations => [organization]
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:input_hash) { {:space => space} }
|
23
|
-
let(:inputs) { Mothership::Inputs.new(nil, nil, input_hash) }
|
24
|
-
let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
|
25
|
-
let(:populator) { CF::Populators::Space.new(inputs, organization) }
|
26
2
|
|
27
|
-
|
28
|
-
|
29
|
-
stub(client).space { space }
|
30
|
-
any_instance_of(described_class) do |instance|
|
31
|
-
stub(instance).client { client }
|
32
|
-
end
|
3
|
+
module CF
|
4
|
+
module Populators
|
33
5
|
|
34
|
-
|
35
|
-
|
6
|
+
describe Space do
|
7
|
+
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
36
8
|
|
37
|
-
|
38
|
-
|
39
|
-
|
9
|
+
describe "#populate_and_save!" do
|
10
|
+
let(:tokens_file_path) { "~/.cf/tokens.yml" }
|
11
|
+
let(:spaces) {
|
12
|
+
[double(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
|
13
|
+
double(:space, :name => "Staging", :guid => "space-id-2")]
|
14
|
+
}
|
40
15
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
16
|
+
let(:user) { build(:user) }
|
17
|
+
let(:organization) { double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
|
18
|
+
let(:space) { spaces.first }
|
19
|
+
let(:client) do
|
20
|
+
fake_client :organizations => [organization]
|
21
|
+
end
|
47
22
|
|
48
|
-
|
23
|
+
let(:input_hash) { {:space => space} }
|
24
|
+
let(:inputs) { Mothership::Inputs.new(nil, nil, input_hash) }
|
25
|
+
let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
|
26
|
+
let(:populator) { CF::Populators::Space.new(inputs, organization) }
|
49
27
|
|
50
|
-
|
51
|
-
|
28
|
+
before do
|
29
|
+
client.stub(:current_user).and_return(user)
|
30
|
+
client.stub(:space).and_return(space)
|
31
|
+
described_class.any_instance.stub(:client).and_return(client)
|
52
32
|
|
53
|
-
|
54
|
-
|
55
|
-
end
|
33
|
+
write_token_file({:space => "space-id-1", :organization => "organization-id-1"})
|
34
|
+
end
|
56
35
|
|
57
|
-
|
58
|
-
|
59
|
-
Mothership::Inputs.new(nil, nil, input_hash).tap do |input|
|
60
|
-
mock(input).[](:space, organization) { space }
|
61
|
-
stub(input).[](anything) { space }
|
36
|
+
subject do
|
37
|
+
capture_output { populator.populate_and_save! }
|
62
38
|
end
|
63
|
-
end
|
64
39
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
40
|
+
it "updates the client with the new space" do
|
41
|
+
write_token_file({:space => "space-id-2"})
|
42
|
+
described_class.any_instance.unstub(:client)
|
43
|
+
populator.client.current_space.guid.should == "space-id-2"
|
69
44
|
|
70
|
-
|
71
|
-
let(:input_hash) { {:space => space} }
|
72
|
-
before { write_token_file({:space => "space-id-2"}) }
|
45
|
+
subject
|
73
46
|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
47
|
+
populator.client.current_space.guid.should == "space-id-1"
|
48
|
+
end
|
77
49
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
50
|
+
it "returns the space" do
|
51
|
+
subject.should == space
|
52
|
+
end
|
82
53
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
54
|
+
describe "mothership input arguments" do
|
55
|
+
let(:inputs) do
|
56
|
+
Mothership::Inputs.new(nil, nil, input_hash).tap do |input|
|
57
|
+
input.should_receive(:[]).with(:space, organization).and_return(space)
|
58
|
+
input.stub(:[]).and_return(space)
|
59
|
+
end
|
60
|
+
end
|
87
61
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
62
|
+
it "passes through extra arguments to the input call" do
|
63
|
+
subject
|
64
|
+
end
|
65
|
+
end
|
93
66
|
|
94
|
-
|
95
|
-
|
67
|
+
context "with a space in the input" do
|
68
|
+
let(:input_hash) { {:space => space} }
|
69
|
+
before { write_token_file({:space => "space-id-2"}) }
|
96
70
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
subject
|
101
|
-
end
|
71
|
+
it "uses that space" do
|
72
|
+
subject.should == space
|
73
|
+
end
|
102
74
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
75
|
+
it "should not reprompt for space" do
|
76
|
+
dont_allow_ask("Space", anything)
|
77
|
+
subject
|
78
|
+
end
|
107
79
|
|
108
|
-
|
109
|
-
|
80
|
+
it "sets the space in the token file" do
|
81
|
+
subject
|
82
|
+
expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
|
83
|
+
end
|
110
84
|
|
111
|
-
it "
|
112
|
-
mock_ask("Space", anything) { space }
|
85
|
+
it "prints out that it is switching to that space" do
|
113
86
|
subject
|
87
|
+
expect(output).to say("Switching to space #{space.name}")
|
114
88
|
end
|
115
89
|
end
|
116
|
-
end
|
117
90
|
|
118
|
-
|
119
|
-
|
91
|
+
context "without a space in the input" do
|
92
|
+
let(:input_hash) { {} }
|
120
93
|
|
121
|
-
|
122
|
-
|
123
|
-
|
94
|
+
context "with a space in the config file" do
|
95
|
+
it "should not reprompt for space" do
|
96
|
+
dont_allow_ask("Space", anything)
|
97
|
+
subject
|
98
|
+
end
|
124
99
|
|
125
|
-
|
126
|
-
|
100
|
+
it "sets the space in the token file" do
|
101
|
+
subject
|
102
|
+
expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
|
103
|
+
end
|
127
104
|
|
128
|
-
|
129
|
-
|
105
|
+
context "but that space doesn't exist anymore (not valid)" do
|
106
|
+
before { space.stub(:developers).and_raise(CFoundry::APIError) }
|
130
107
|
|
131
|
-
|
132
|
-
|
133
|
-
|
108
|
+
it "asks the user for an space" do
|
109
|
+
mock_ask("Space", anything) { space }
|
110
|
+
subject
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "without a space in the config file" do
|
116
|
+
before { write_token_file({}) }
|
117
|
+
|
118
|
+
it "prompts for the space" do
|
119
|
+
mock_ask("Space", anything) { space }
|
120
|
+
subject
|
121
|
+
|
122
|
+
expect(output).to say("Switching to space #{space.name}")
|
123
|
+
end
|
124
|
+
|
125
|
+
it "sets the space in the token file" do
|
126
|
+
mock_ask("Space", anything) { space }
|
127
|
+
|
128
|
+
subject
|
129
|
+
expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
|
130
|
+
end
|
134
131
|
|
135
|
-
|
136
|
-
|
132
|
+
context "when the user has no spaces in that organization" do
|
133
|
+
let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]) }
|
137
134
|
|
138
|
-
|
139
|
-
|
135
|
+
it "tells the user to create one by raising a UserFriendlyError" do
|
136
|
+
expect { subject }.to raise_error(CF::UserFriendlyError, /There are no spaces/)
|
137
|
+
end
|
138
|
+
end
|
140
139
|
end
|
141
140
|
end
|
142
141
|
end
|