cf 0.1.5 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1277 -30
- data/Rakefile +12 -1
- data/bin/cf +0 -3
- data/lib/cf.rb +6 -0
- data/lib/cf/cli.rb +389 -190
- data/lib/cf/cli/app/app.rb +45 -0
- data/lib/cf/cli/app/apps.rb +99 -0
- data/lib/cf/cli/app/base.rb +90 -0
- data/lib/cf/cli/app/crashes.rb +42 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +78 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +105 -0
- data/lib/cf/cli/app/push/create.rb +149 -0
- data/lib/cf/cli/app/push/interactions.rb +94 -0
- data/lib/cf/cli/app/push/sync.rb +64 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +20 -0
- data/lib/cf/cli/app/scale.rb +69 -0
- data/lib/cf/cli/app/start.rb +143 -0
- data/lib/cf/cli/app/stats.rb +67 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +8 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +105 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +32 -0
- data/lib/cf/cli/organization/delete.rb +73 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +35 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/route/base.rb +8 -0
- data/lib/cf/cli/route/map.rb +70 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +62 -0
- data/lib/cf/cli/service/base.rb +8 -0
- data/lib/cf/cli/service/bind.rb +44 -0
- data/lib/cf/cli/service/create.rb +107 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/services.rb +99 -0
- data/lib/cf/cli/service/unbind.rb +38 -0
- data/lib/cf/cli/space/base.rb +19 -0
- data/lib/cf/cli/space/create.rb +63 -0
- data/lib/cf/cli/space/delete.rb +95 -0
- data/lib/cf/cli/space/rename.rb +39 -0
- data/lib/cf/cli/space/space.rb +64 -0
- data/lib/cf/cli/space/spaces.rb +55 -0
- data/lib/cf/cli/space/switch.rb +16 -0
- data/lib/cf/cli/start/base.rb +93 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/info.rb +124 -0
- data/lib/cf/cli/start/login.rb +94 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +69 -0
- data/lib/cf/cli/start/target_interactions.rb +37 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +39 -0
- data/lib/cf/cli/user/passwd.rb +43 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -7
- data/lib/cf/detect.rb +113 -48
- data/lib/cf/errors.rb +17 -0
- data/lib/cf/plugin.rb +28 -12
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +1 -1
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +6 -0
- data/spec/assets/specker_runner/specker_runner_input.rb +6 -0
- data/spec/assets/specker_runner/specker_runner_pause.rb +5 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +188 -0
- data/spec/cf/cli/app/instances_spec.rb +65 -0
- data/spec/cf/cli/app/push/create_spec.rb +661 -0
- data/spec/cf/cli/app/push_spec.rb +369 -0
- data/spec/cf/cli/app/rename_spec.rb +104 -0
- data/spec/cf/cli/app/scale_spec.rb +75 -0
- data/spec/cf/cli/app/start_spec.rb +208 -0
- data/spec/cf/cli/app/stats_spec.rb +68 -0
- data/spec/cf/cli/domain/map_spec.rb +130 -0
- data/spec/cf/cli/domain/unmap_spec.rb +69 -0
- data/spec/cf/cli/organization/orgs_spec.rb +108 -0
- data/spec/cf/cli/organization/rename_spec.rb +113 -0
- data/spec/cf/cli/route/map_spec.rb +121 -0
- data/spec/cf/cli/route/unmap_spec.rb +155 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/rename_spec.rb +105 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/create_spec.rb +93 -0
- data/spec/cf/cli/space/rename_spec.rb +102 -0
- data/spec/cf/cli/space/spaces_spec.rb +104 -0
- data/spec/cf/cli/space/switch_space_spec.rb +55 -0
- data/spec/cf/cli/start/info_spec.rb +160 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +50 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +54 -0
- data/spec/cf/cli/user/passwd_spec.rb +102 -0
- data/spec/cf/cli/user/register_spec.rb +140 -0
- data/spec/cf/cli_spec.rb +442 -0
- data/spec/cf/detect_spec.rb +54 -0
- data/spec/console_app_specker/console_app_specker_matchers_spec.rb +173 -0
- data/spec/console_app_specker/specker_runner_spec.rb +167 -0
- data/spec/features/account_lifecycle_spec.rb +85 -0
- data/spec/features/login_spec.rb +66 -0
- data/spec/features/push_flow_spec.rb +125 -0
- data/spec/features/switching_targets_spec.rb +32 -0
- data/spec/spec_helper.rb +72 -0
- data/spec/support/command_helper.rb +81 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/console_app_specker_matchers.rb +86 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/interact_helper.rb +29 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/support/specker_runner.rb +80 -0
- data/spec/support/tracking_expector.rb +71 -0
- metadata +427 -66
- data/lib/cf/cli/app.rb +0 -595
- data/lib/cf/cli/command.rb +0 -444
- data/lib/cf/cli/dots.rb +0 -133
- data/lib/cf/cli/service.rb +0 -112
- data/lib/cf/cli/user.rb +0 -71
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CF::Detector do
|
4
|
+
let(:client) { fake_client :frameworks => [framework] }
|
5
|
+
let(:detector) { CF::Detector.new client, nil }
|
6
|
+
|
7
|
+
describe '#detect_framework' do
|
8
|
+
subject { detector.detect_framework }
|
9
|
+
|
10
|
+
{ Clouseau::Django => "django",
|
11
|
+
Clouseau::DotNet => "dotNet",
|
12
|
+
Clouseau::Grails => "grails",
|
13
|
+
Clouseau::Java => "java_web",
|
14
|
+
Clouseau::Lift => "lift",
|
15
|
+
Clouseau::Node => "node",
|
16
|
+
Clouseau::PHP => "php",
|
17
|
+
Clouseau::Play => "play",
|
18
|
+
Clouseau::Python => "wsgi",
|
19
|
+
Clouseau::Rack => "rack",
|
20
|
+
Clouseau::Rails => "rails3",
|
21
|
+
Clouseau::Sinatra => "sinatra",
|
22
|
+
Clouseau::Spring => "spring"
|
23
|
+
}.each do |clouseau_detective, cf_name|
|
24
|
+
context "when we detected #{clouseau_detective}" do
|
25
|
+
let(:framework) { fake(:framework, :name => cf_name) }
|
26
|
+
|
27
|
+
it "maps to CF name #{cf_name}" do
|
28
|
+
stub(Clouseau).detect(anything) { clouseau_detective }
|
29
|
+
should eq framework
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#detect_runtime' do
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#runtimes' do
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#suggested_memory' do
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#all_runtimes' do
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#all_frameworks' do
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include ConsoleAppSpeckerMatchers
|
3
|
+
|
4
|
+
describe ConsoleAppSpeckerMatchers, :ruby19 => true do
|
5
|
+
describe "#say" do
|
6
|
+
it "returns an ExpectOutputMatcher" do
|
7
|
+
say("").should be_a(ExpectOutputMatcher)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "with an explicit timeout" do
|
11
|
+
it "returns an ExpectOutputMatcher" do
|
12
|
+
matcher = say("", 30)
|
13
|
+
matcher.should be_a(ExpectOutputMatcher)
|
14
|
+
matcher.timeout.should == 30
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#have_exited_with" do
|
20
|
+
it "returns an ExitCodeMatcher" do
|
21
|
+
have_exited_with(1).should be_a(ExitCodeMatcher)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has synonyms" do
|
25
|
+
exit_with(1).should be_a(ExitCodeMatcher)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ExpectOutputMatcher, :ruby19 => true do
|
31
|
+
let(:expected_output) { "expected_output" }
|
32
|
+
let(:timeout) { 1 }
|
33
|
+
|
34
|
+
subject { ExpectOutputMatcher.new(expected_output, timeout) }
|
35
|
+
|
36
|
+
describe "#matches?" do
|
37
|
+
context "with something that isn't a runner" do
|
38
|
+
it "raises an exception" do
|
39
|
+
expect {
|
40
|
+
subject.matches?("c'est ne pas une specker runner")
|
41
|
+
}.to raise_exception(InvalidInputError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with a valid runner" do
|
46
|
+
context "when the expected output is in the process output" do
|
47
|
+
it "finds the expected output" do
|
48
|
+
run("echo -n expected_output") do |runner|
|
49
|
+
subject.matches?(runner).should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the expected output is not in the process output" do
|
55
|
+
let(:runner) { SpeckerRunner.new('echo -n not_what_we_were_expecting') }
|
56
|
+
|
57
|
+
it "does not find the expected output" do
|
58
|
+
run("echo -n not_what_we_were_expecting") do |runner|
|
59
|
+
subject.matches?(runner).should be_false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "failure messages" do
|
67
|
+
it "has a correct failure message" do
|
68
|
+
run("echo -n actual_output") do |runner|
|
69
|
+
subject.matches?(runner)
|
70
|
+
subject.failure_message.should == "expected 'expected_output' to be printed, but it wasn't. full output:\nactual_output"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "has a correct negative failure message" do
|
75
|
+
run("echo -n actual_output") do |runner|
|
76
|
+
subject.matches?(runner)
|
77
|
+
subject.negative_failure_message.should == "expected 'expected_output' to not be printed, but it was. full output:\nactual_output"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when expecting branching output" do
|
82
|
+
let(:expected_output) { {
|
83
|
+
"expected_output" => proc {},
|
84
|
+
"other_expected_output" => proc {}
|
85
|
+
} }
|
86
|
+
|
87
|
+
it "has a correct failure message" do
|
88
|
+
run("echo -n actual_output") do |runner|
|
89
|
+
subject.matches?(runner)
|
90
|
+
subject.failure_message.should == "expected one of 'expected_output', 'other_expected_output' to be printed, but it wasn't. full output:\nactual_output"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "has a correct negative failure message" do
|
95
|
+
run("echo -n expected_output") do |runner|
|
96
|
+
subject.matches?(runner)
|
97
|
+
subject.negative_failure_message.should == "expected 'expected_output' to not be printed, but it was. full output:\nexpected_output"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ExitCodeMatcher, :ruby19 => true do
|
105
|
+
let(:expected_code) { 0 }
|
106
|
+
|
107
|
+
subject { ExitCodeMatcher.new(expected_code) }
|
108
|
+
|
109
|
+
describe "#matches?" do
|
110
|
+
context "with something that isn't a runner" do
|
111
|
+
it "raises an exception" do
|
112
|
+
expect {
|
113
|
+
subject.matches?("c'est ne pas une specker runner")
|
114
|
+
}.to raise_exception(InvalidInputError)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "with a valid runner" do
|
119
|
+
context "and the command exited with the expected exit code" do
|
120
|
+
it "returns true" do
|
121
|
+
run("true") do |runner|
|
122
|
+
subject.matches?(runner).should be_true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "and the command exits with a different exit code" do
|
128
|
+
it "returns false" do
|
129
|
+
run("false") do |runner|
|
130
|
+
subject.matches?(runner).should be_false
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "and the command runs for a while" do
|
136
|
+
it "waits for it to exit" do
|
137
|
+
run("sleep 0.5") do |runner|
|
138
|
+
subject.matches?(runner).should be_true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "failure messages" do
|
146
|
+
context "with a command that's exited" do
|
147
|
+
it "has a correct failure message" do
|
148
|
+
run("false") do |runner|
|
149
|
+
subject.matches?(runner)
|
150
|
+
runner.wait_for_exit
|
151
|
+
subject.failure_message.should == "expected process to exit with status 0, but it exited with status 1"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it "has a correct negative failure message" do
|
156
|
+
run("false") do |runner|
|
157
|
+
subject.matches?(runner)
|
158
|
+
runner.wait_for_exit
|
159
|
+
subject.negative_failure_message.should == "expected process to not exit with status 0, but it did"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "with a command that's still running" do
|
165
|
+
it "waits for it to exit" do
|
166
|
+
run("ruby -e 'sleep 1; exit 1'") do |runner|
|
167
|
+
subject.matches?(runner)
|
168
|
+
subject.failure_message.should == "expected process to exit with status 0, but it exited with status 1"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SpeckerRunner, :ruby19 => true do
|
4
|
+
def asset(file)
|
5
|
+
File.expand_path("../../assets/specker_runner/#{file}", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:timeout) { 1 }
|
9
|
+
|
10
|
+
describe "running a command" do
|
11
|
+
let(:file) do
|
12
|
+
file = Tempfile.new('test-specker-runner')
|
13
|
+
sleep 1 # wait one second to make sure touching the file does something measurable
|
14
|
+
file
|
15
|
+
end
|
16
|
+
|
17
|
+
after { file.unlink }
|
18
|
+
|
19
|
+
it "runs a command" do
|
20
|
+
run("touch -a #{file.path}") do |runner|
|
21
|
+
runner.wait_for_exit
|
22
|
+
file.stat.atime.should > file.stat.mtime
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#expect" do
|
28
|
+
context "when the expected output shows up" do
|
29
|
+
it "returns a truthy value" do
|
30
|
+
run("echo -n foo") do |runner|
|
31
|
+
expect(runner.expect('foo')).to be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when the expected output never shows up" do
|
37
|
+
it "returns nil" do
|
38
|
+
run("echo the spanish inquisition") do |runner|
|
39
|
+
expect(runner.expect("something else", 0.5)).to be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when the output eventually shows up" do
|
45
|
+
it "returns a truthy value" do
|
46
|
+
run("ruby #{asset("specker_runner_pause.rb")}") do |runner|
|
47
|
+
expect(runner.expect("finished")).to be_true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "backspace" do
|
53
|
+
it "respects the backspace character" do
|
54
|
+
run("ruby -e 'puts \"foo a\\bbar\"'") do |runner|
|
55
|
+
expect(runner.expect("foo bar")).to be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "does not go beyond the beginning of the line" do
|
60
|
+
run("ruby -e 'print \"foo abc\nx\\b\\bd\"'") do |runner|
|
61
|
+
expect(runner.expect("foo abc\nd")).to be_true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "does not go beyond the beginning of the string" do
|
66
|
+
run("ruby -e 'print \"f\\b\\bbar\"'") do |runner|
|
67
|
+
expect(runner.expect("bar")).to be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "leaves backspaced characters in the buffer until they're overwritten" do
|
72
|
+
run("ruby -e 'print \"foo abc\\b\\bd\"'") do |runner|
|
73
|
+
expect(runner.expect("foo adc")).to be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "ansi escape sequences" do
|
79
|
+
it "filters ansi color sequences" do
|
80
|
+
run("ruby -e 'puts \"\\e[36mblue\\e[0m thing\"'") do |runner|
|
81
|
+
expect(runner.expect("blue thing")).to be_true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "expecting multiple branches" do
|
87
|
+
context "and one of them matches" do
|
88
|
+
it "can be passed a hash of values with callbacks, and returns the matched key" do
|
89
|
+
run("echo 1 3") do |runner|
|
90
|
+
branches = {
|
91
|
+
"1" => proc { 1 },
|
92
|
+
"2" => proc { 2 },
|
93
|
+
"3" => proc { 3 }
|
94
|
+
}
|
95
|
+
|
96
|
+
expect(runner.expect(branches)).to eq "1"
|
97
|
+
expect(runner.expect(branches)).to eq "3"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "calls the matched callback" do
|
102
|
+
callback = mock!
|
103
|
+
run("echo 1 3") do |runner|
|
104
|
+
branches = {
|
105
|
+
"1" => proc { callback }
|
106
|
+
}
|
107
|
+
runner.expect(branches)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "and none of them match" do
|
113
|
+
it "returns nil when none of the branches match" do
|
114
|
+
run("echo not_a_number") do |runner|
|
115
|
+
expect(runner.expect({"1" => proc { 1 }}, timeout)).to be_nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#output" do
|
123
|
+
it "makes the entire command output (so far) available" do
|
124
|
+
run("echo 0 1 2 3") do |runner|
|
125
|
+
runner.expect("1")
|
126
|
+
runner.expect("3")
|
127
|
+
expect(runner.output).to eq "0 1 2 3"
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#send_keys" do
|
134
|
+
it "sends input and expects more output afterward" do
|
135
|
+
run("ruby #{asset("specker_runner_input.rb")}") do |runner|
|
136
|
+
expect(runner.expect("started")).to be_true
|
137
|
+
runner.send_keys("foo")
|
138
|
+
expect(runner.expect("foo")).to be_true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "#exit_code" do
|
144
|
+
it "returns the exit code" do
|
145
|
+
run("ruby -e 'exit 42'") do |runner|
|
146
|
+
runner.wait_for_exit
|
147
|
+
expect(runner.exit_code).to eq(42)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "when the command is still running" do
|
152
|
+
it "waits for the command to exit" do
|
153
|
+
run("sleep 0.5") do |runner|
|
154
|
+
expect(runner.exit_code).to eq(0)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context "#exited?" do
|
161
|
+
it "returns false if the command is still running" do
|
162
|
+
run("sleep 10") do |runner|
|
163
|
+
expect(runner.exited?).to eq false
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "webmock/rspec"
|
3
|
+
require "ffaker"
|
4
|
+
|
5
|
+
if ENV['CF_V2_TEST_USER'] && ENV['CF_V2_TEST_PASSWORD'] && ENV['CF_V2_TEST_TARGET']
|
6
|
+
describe 'A new user tries to use CF against v2 production', :ruby19 => true do
|
7
|
+
before(:all) do
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:target) { ENV['CF_V2_TEST_TARGET'] }
|
16
|
+
let(:username) { ENV['CF_V2_TEST_USER'] }
|
17
|
+
let(:password) { ENV['CF_V2_TEST_PASSWORD'] }
|
18
|
+
|
19
|
+
let(:client) do
|
20
|
+
client = CFoundry::V2::Client.new("https://#{target}")
|
21
|
+
client.login(username, password)
|
22
|
+
client
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
Interact::Progress::Dots.start!
|
27
|
+
end
|
28
|
+
|
29
|
+
after do
|
30
|
+
Interact::Progress::Dots.stop!
|
31
|
+
end
|
32
|
+
|
33
|
+
it "registers a new account and deletes it" do
|
34
|
+
pending "until we get some v2 admin credentials somewhere to actually run this with" if TRAVIS_BUILD_ID
|
35
|
+
|
36
|
+
email = Faker::Internet.email
|
37
|
+
run("#{cf_bin} target #{target}") do |runner|
|
38
|
+
runner.wait_for_exit
|
39
|
+
end
|
40
|
+
|
41
|
+
run("#{cf_bin} login #{username} --password #{password}") do |runner|
|
42
|
+
expect(runner).to say "Organization>"
|
43
|
+
runner.send_keys "1"
|
44
|
+
expect(runner).to say "Space>"
|
45
|
+
runner.send_keys "1"
|
46
|
+
end
|
47
|
+
|
48
|
+
puts "registering #{email}"
|
49
|
+
run("#{cf_bin} register #{email} --password p") do |runner|
|
50
|
+
expect(runner).to say "Confirm Password>"
|
51
|
+
runner.send_keys 'p'
|
52
|
+
expect(runner).to say "Your password strength is: good"
|
53
|
+
expect(runner).to say "Creating user... OK"
|
54
|
+
expect(runner).to say "Authenticating... OK"
|
55
|
+
end
|
56
|
+
|
57
|
+
run("#{cf_bin} logout") do |runner|
|
58
|
+
runner.wait_for_exit
|
59
|
+
end
|
60
|
+
|
61
|
+
run("#{cf_bin} login #{username} --password #{password}") do |runner|
|
62
|
+
expect(runner).to say "Organization>"
|
63
|
+
runner.send_keys "1"
|
64
|
+
expect(runner).to say "Space>"
|
65
|
+
runner.send_keys "1"
|
66
|
+
end
|
67
|
+
|
68
|
+
# run("#{cf_bin} delete-user #{email}") do |runner|
|
69
|
+
# expect(runner).to say "Really delete user #{email}?>"
|
70
|
+
# runner.send_keys "y"
|
71
|
+
# expect(runner).to say "Deleting #{email}... OK"
|
72
|
+
# end
|
73
|
+
|
74
|
+
puts "deleting #{email}"
|
75
|
+
client.login(email, "p")
|
76
|
+
user = client.current_user
|
77
|
+
guid = user.guid
|
78
|
+
client.login(username, password)
|
79
|
+
user.delete!
|
80
|
+
client.base.uaa.delete_user(guid)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
else
|
84
|
+
$stderr.puts 'Skipping v2 integration specs; please provide $CF_V2_TEST_TARGET, $CF_V2_TEST_USER, and $CF_V2_TEST_PASSWORD'
|
85
|
+
end
|