af-addon-tester 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -4
- data/bin/af-addon-tester +21 -21
- data/config/manifest.example.json +2 -2
- data/lib/af-addon-tester/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -24,16 +24,16 @@ Example
|
|
24
24
|
|
25
25
|
{
|
26
26
|
"id":"myaddon",
|
27
|
+
"plans":[
|
28
|
+
{"id":"free"}
|
29
|
+
],
|
27
30
|
"api":{
|
28
|
-
"plans":[
|
29
|
-
{"id":"free"}
|
30
|
-
],
|
31
31
|
"config_vars": {
|
32
32
|
"MYADDON_URL":"http://some.url.com",
|
33
33
|
"MYADDON_VAR1":"cats",
|
34
34
|
"MYADDON_VAR2":"dogs"
|
35
35
|
},
|
36
|
-
"test":"http://localhost:4567
|
36
|
+
"test":"http://localhost:4567",
|
37
37
|
"password":"cavef6azebRewruvecuch",
|
38
38
|
"sso_salt":"8ouy3ayLEyOA7HLAKO2Yo"
|
39
39
|
}
|
data/bin/af-addon-tester
CHANGED
@@ -27,7 +27,6 @@ begin
|
|
27
27
|
raise "Manifest must have atleast one plan" if manifest['plans'].nil? || manifest['plans'][0].nil? || manifest['plans'][0]['id'].nil?
|
28
28
|
raise "missing api config_vars" if manifest['api']['config_vars'].nil?
|
29
29
|
raise "Missing api sso_salt" if manifest['api']['sso_salt'].nil?
|
30
|
-
|
31
30
|
rescue Exception => e
|
32
31
|
puts bwhite "#{e.message}. Please specify a valid manifest file."
|
33
32
|
exit
|
@@ -37,22 +36,23 @@ callback_url = 'http://localhost:9990'
|
|
37
36
|
config_prefix = manifest['id'].gsub('-','_').upcase + '_'
|
38
37
|
bad_user = 'bad_user'
|
39
38
|
bad_password = 'bad_pass'
|
39
|
+
resources_path = (manifest['api']['path'] || 'appfog/resources').gsub(/^\/+/,'')
|
40
40
|
|
41
41
|
addon = RestClient::Resource.new manifest['api']['test'], {:user => username, :password => manifest['api']['password']}
|
42
42
|
headers = { :accept => "application/json", :content_type => "application/json", "User-Agent" => "af-addon-tester/#{VERSION}" }
|
43
|
-
|
43
|
+
|
44
44
|
resp = nil
|
45
45
|
code = nil
|
46
46
|
|
47
47
|
validate "Provisioning" do
|
48
|
-
payload = { 'customer_id' =>
|
48
|
+
payload = { 'customer_id' => "test@test.com", 'plan' => 'test', 'callback_url' => callback_url, 'options' => '{}' }
|
49
49
|
begin
|
50
|
-
resp = addon[
|
50
|
+
resp = addon[resources_path].post JSON.generate(payload), headers
|
51
51
|
failed("response code: #{resp.code}") if resp.code != 200
|
52
|
-
code =
|
52
|
+
code = resp.code
|
53
53
|
rescue RestClient::ExceptionWithResponse => rest_err
|
54
54
|
code = rest_err.http_code
|
55
|
-
failed("response code: #{rest_err.message}")
|
55
|
+
failed("response code: #{rest_err.message}")
|
56
56
|
end
|
57
57
|
passed
|
58
58
|
end
|
@@ -62,7 +62,7 @@ end
|
|
62
62
|
validate "Valid JSON response" do
|
63
63
|
begin
|
64
64
|
provision_info = JSON.parse(resp.body)
|
65
|
-
rescue Exception => e
|
65
|
+
rescue Exception => e
|
66
66
|
failed e.message
|
67
67
|
end
|
68
68
|
passed
|
@@ -72,7 +72,7 @@ end
|
|
72
72
|
validate "Response params" do
|
73
73
|
begin
|
74
74
|
failed("Missing 'id'") if provision_info['id'].nil? || provision_info['id'] == ""
|
75
|
-
rescue Exception => e
|
75
|
+
rescue Exception => e
|
76
76
|
failed e.message
|
77
77
|
end
|
78
78
|
passed
|
@@ -102,12 +102,12 @@ end
|
|
102
102
|
resource_id = provision_info['id']
|
103
103
|
unless resource_id.nil?
|
104
104
|
validate "Update resource" do
|
105
|
-
payload = { 'customer_id' => manifest['id'], 'plan' => '
|
105
|
+
payload = { 'customer_id' => manifest['id'], 'plan' => manifest['plans'][0]['id'] }
|
106
106
|
begin
|
107
|
-
resp = addon[
|
107
|
+
resp = addon[File.join(resources_path, resource_id.to_s)].put JSON.generate(payload), headers
|
108
108
|
failed("response code: #{resp.code}") if resp.code != 200
|
109
109
|
rescue RestClient::ExceptionWithResponse => rest_err
|
110
|
-
failed("response code: #{rest_err.message}")
|
110
|
+
failed("response code: #{rest_err.message}")
|
111
111
|
end
|
112
112
|
passed
|
113
113
|
end
|
@@ -131,7 +131,7 @@ end
|
|
131
131
|
passed
|
132
132
|
end
|
133
133
|
|
134
|
-
callback_info = nil
|
134
|
+
callback_info = nil
|
135
135
|
isValidCallback = false
|
136
136
|
validate "Valid callback response" do
|
137
137
|
_, json = out.split("\r\n\r\n")
|
@@ -165,7 +165,7 @@ end
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
validate "SSO link" do
|
170
170
|
timestamp = Time.now.to_i
|
171
171
|
authstring = resource_id.to_s + ':' + manifest['api']['sso_salt'] + ':' + timestamp.to_s
|
@@ -173,19 +173,19 @@ end
|
|
173
173
|
addon_sso = RestClient::Resource.new manifest['api']['test']
|
174
174
|
sso_headers = { :accept => "text/html", :content_type => "text/html", "User-Agent" => "af-addon-tester/#{VERSION}" }
|
175
175
|
begin
|
176
|
-
resp = addon_sso["
|
176
|
+
resp = addon_sso[File.join(resources_path, resource_id.to_s) + "?token=#{token}×tamp=#{timestamp}"].get sso_headers
|
177
177
|
failed("response code: #{resp.code}") if resp.code != 200
|
178
178
|
rescue RestClient::ExceptionWithResponse => rest_err
|
179
|
-
failed("response code: #{rest_err.message}")
|
179
|
+
failed("response code: #{rest_err.message}")
|
180
180
|
end
|
181
181
|
passed
|
182
182
|
end
|
183
183
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
184
|
+
validate "Deprovision" do
|
185
|
+
resp = addon[File.join(resources_path, resource_id.to_s)].delete
|
186
|
+
failed("response code: #{resp.code}") if resp.code != 200
|
187
|
+
passed
|
188
|
+
end
|
189
189
|
|
190
190
|
end
|
191
191
|
end
|
@@ -201,7 +201,7 @@ validate "Bad credentials test" do
|
|
201
201
|
|
202
202
|
code = nil
|
203
203
|
begin
|
204
|
-
resp = addon_bad_auth[
|
204
|
+
resp = addon_bad_auth[File.join(resources_path, resource_id.to_s)].post JSON.generate(payload), headers
|
205
205
|
code = resp.code
|
206
206
|
rescue RestClient::ExceptionWithResponse => rest_err
|
207
207
|
code = rest_err.http_code
|
@@ -9,8 +9,8 @@
|
|
9
9
|
"MYADDON_VAR1":"cats",
|
10
10
|
"MYADDON_VAR2":"dogs"
|
11
11
|
},
|
12
|
-
"test":"http://localhost:4567",
|
13
|
-
"
|
12
|
+
"test":"http://localhost:4567/",
|
13
|
+
"path":"/myaddon/resources",
|
14
14
|
"password":"NVUQ1OqNtuc74HiE",
|
15
15
|
"sso_salt":"8ouy3ayLEyOA7HLAKO2Yo"
|
16
16
|
}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tim Santeford
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-01-
|
17
|
+
date: 2012-01-17 00:00:00 -08:00
|
18
18
|
default_executable: af-addon-tester
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|