af-addon-tester 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/af-addon-tester.gemspec +1 -0
- data/bin/af-addon-tester +30 -10
- data/lib/af-addon-tester/version.rb +1 -1
- metadata +15 -3
data/af-addon-tester.gemspec
CHANGED
data/bin/af-addon-tester
CHANGED
@@ -8,6 +8,9 @@ require 'json'
|
|
8
8
|
require 'digest/sha1'
|
9
9
|
require 'af-addon-tester'
|
10
10
|
require 'restclient'
|
11
|
+
require 'uuid'
|
12
|
+
|
13
|
+
puts "AppFog Addon Tester v#{AppFog::AddonTester::VERSION}"
|
11
14
|
|
12
15
|
manifest_path = ARGV.last
|
13
16
|
|
@@ -20,7 +23,6 @@ begin
|
|
20
23
|
manifest = JSON.parse(manifest_json)
|
21
24
|
|
22
25
|
raise "Missing id" if manifest['id'].nil?
|
23
|
-
username = manifest['api']['username'] || manifest['id']
|
24
26
|
raise "Missing api section" if manifest['api'].nil?
|
25
27
|
raise "Missing api password" if manifest['api']['password'].nil?
|
26
28
|
raise "Missing apt test url" if manifest['api']['test'].nil?
|
@@ -32,20 +34,37 @@ rescue Exception => e
|
|
32
34
|
exit
|
33
35
|
end
|
34
36
|
|
37
|
+
customer_id = "phpfog#{UUID.new.generate}@appfog.com"
|
35
38
|
callback_url = 'http://localhost:9990'
|
39
|
+
plan = manifest['plans'][0]['id']
|
36
40
|
config_prefix = manifest['id'].gsub('-','_').upcase + '_'
|
41
|
+
username = manifest['api']['username'] || manifest['id']
|
42
|
+
password = manifest['api']['password']
|
37
43
|
bad_user = 'bad_user'
|
38
44
|
bad_password = 'bad_pass'
|
45
|
+
resource_host = manifest['api']['test']
|
39
46
|
resources_path = (manifest['api']['path'] || 'appfog/resources').gsub(/^\/+/,'')
|
40
|
-
|
41
|
-
|
47
|
+
sso_salt = manifest['api']['sso_salt']
|
48
|
+
|
49
|
+
puts ""
|
50
|
+
puts " Target: #{bwhite(resource_host + resources_path)}"
|
51
|
+
puts " Customer ID: #{bwhite(customer_id)}"
|
52
|
+
puts " Plan: #{bwhite(manifest['plans'][0]['id'])}"
|
53
|
+
puts " Callback URL: #{bwhite(callback_url)}"
|
54
|
+
puts " Config Prefix: #{bwhite(config_prefix)}"
|
55
|
+
puts " Basic Auth User: #{bwhite(username)}"
|
56
|
+
puts " Basic Auth Password: #{bwhite(password[0..2]+password[3..-1].gsub(/./,'*'))}"
|
57
|
+
puts " SSO Salt: #{bwhite(sso_salt[0..2]+sso_salt[3..-1].gsub(/./,'*'))}"
|
58
|
+
puts ""
|
59
|
+
|
60
|
+
addon = RestClient::Resource.new resource_host, {:user => username, :password => password}
|
42
61
|
headers = { :accept => "application/json", :content_type => "application/json", "User-Agent" => "af-addon-tester/#{VERSION}" }
|
43
62
|
|
44
63
|
resp = nil
|
45
64
|
code = nil
|
46
65
|
|
47
66
|
validate "Provisioning" do
|
48
|
-
payload = { 'customer_id' =>
|
67
|
+
payload = { 'customer_id' => customer_id, 'plan' => plan, 'callback_url' => callback_url, 'options' => '{}' }
|
49
68
|
begin
|
50
69
|
resp = addon[resources_path].post JSON.generate(payload), headers
|
51
70
|
failed("response code: #{resp.code}") if resp.code != 200
|
@@ -102,7 +121,7 @@ end
|
|
102
121
|
resource_id = provision_info['id']
|
103
122
|
unless resource_id.nil?
|
104
123
|
validate "Update resource" do
|
105
|
-
payload = { 'customer_id' =>
|
124
|
+
payload = { 'customer_id' => customer_id, 'plan' => plan }
|
106
125
|
begin
|
107
126
|
resp = addon[File.join(resources_path, resource_id.to_s)].put JSON.generate(payload), headers
|
108
127
|
failed("response code: #{resp.code}") if resp.code != 200
|
@@ -168,13 +187,14 @@ end
|
|
168
187
|
|
169
188
|
validate "SSO link" do
|
170
189
|
timestamp = Time.now.to_i
|
171
|
-
authstring = resource_id.to_s + ':' +
|
190
|
+
authstring = resource_id.to_s + ':' + sso_salt + ':' + timestamp.to_s
|
172
191
|
token = Digest::SHA1.hexdigest(authstring)
|
173
|
-
addon_sso = RestClient::Resource.new
|
192
|
+
addon_sso = RestClient::Resource.new resource_host
|
174
193
|
sso_headers = { :accept => "text/html", :content_type => "text/html", "User-Agent" => "af-addon-tester/#{VERSION}" }
|
175
194
|
begin
|
195
|
+
expected = [200, 301, 302, 303, 304, 307]
|
176
196
|
resp = addon_sso[File.join(resources_path, resource_id.to_s) + "?token=#{token}×tamp=#{timestamp}"].get sso_headers
|
177
|
-
failed("response code: #{resp.code}") if resp.code
|
197
|
+
failed("response code: #{resp.code}") if !expected.include?(resp.code)
|
178
198
|
rescue RestClient::ExceptionWithResponse => rest_err
|
179
199
|
failed("response code: #{rest_err.message}")
|
180
200
|
end
|
@@ -195,9 +215,9 @@ else
|
|
195
215
|
end
|
196
216
|
|
197
217
|
validate "Bad credentials test" do
|
198
|
-
payload = { 'customer_id' =>
|
218
|
+
payload = { 'customer_id' => customer_id, 'plan' => plan, 'callback_url' => callback_url, 'options' => '{}' }
|
199
219
|
|
200
|
-
addon_bad_auth = RestClient::Resource.new
|
220
|
+
addon_bad_auth = RestClient::Resource.new resource_host, { :username => bad_user, :password => bad_password }
|
201
221
|
|
202
222
|
code = nil
|
203
223
|
begin
|
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
|
+
- 5
|
9
|
+
version: 0.0.5
|
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-18 00:00:00 -08:00
|
18
18
|
default_executable: af-addon-tester
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -29,6 +29,18 @@ dependencies:
|
|
29
29
|
version: "0"
|
30
30
|
type: :runtime
|
31
31
|
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: uuid
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
32
44
|
description: Allows developers to test App Fog add-ons
|
33
45
|
email:
|
34
46
|
- tim@phpfog.com
|