smog 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +18 -14
- data/bin/smog +0 -2
- data/features/smog.feature +22 -18
- data/features/step_definitions/command_steps.rb +3 -0
- data/features/support/setup.rb +2 -1
- data/lib/smog/cli.rb +59 -30
- data/lib/smog/version.rb +1 -1
- data/smog.gemspec +5 -8
- metadata +11 -11
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smog (0.0.
|
5
|
-
|
4
|
+
smog (0.0.2)
|
5
|
+
main
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
+
arrayfields (4.7.4)
|
10
11
|
aruba (0.2.3)
|
11
12
|
background_process
|
12
13
|
cucumber (~> 0.9.0)
|
@@ -19,22 +20,25 @@ GEM
|
|
19
20
|
json (~> 1.4.6)
|
20
21
|
term-ansicolor (~> 1.0.5)
|
21
22
|
diff-lcs (1.1.2)
|
22
|
-
|
23
|
+
fattr (2.1.0)
|
24
|
+
gherkin (2.2.9)
|
23
25
|
json (~> 1.4.6)
|
24
26
|
term-ansicolor (~> 1.0.5)
|
25
27
|
json (1.4.6)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
main (4.2.0)
|
29
|
+
arrayfields (>= 4.7.4)
|
30
|
+
fattr (>= 2.1.0)
|
31
|
+
rspec (2.0.1)
|
32
|
+
rspec-core (~> 2.0.1)
|
33
|
+
rspec-expectations (~> 2.0.1)
|
34
|
+
rspec-mocks (~> 2.0.1)
|
35
|
+
rspec-core (2.0.1)
|
36
|
+
rspec-expectations (2.0.1)
|
32
37
|
diff-lcs (>= 1.1.2)
|
33
|
-
rspec-mocks (2.0.
|
34
|
-
rspec-core (
|
35
|
-
rspec-expectations (
|
38
|
+
rspec-mocks (2.0.1)
|
39
|
+
rspec-core (~> 2.0.1)
|
40
|
+
rspec-expectations (~> 2.0.1)
|
36
41
|
term-ansicolor (1.0.5)
|
37
|
-
thor (0.14.3)
|
38
42
|
|
39
43
|
PLATFORMS
|
40
44
|
ruby
|
@@ -42,6 +46,6 @@ PLATFORMS
|
|
42
46
|
DEPENDENCIES
|
43
47
|
aruba
|
44
48
|
cucumber
|
49
|
+
main
|
45
50
|
rspec
|
46
51
|
smog!
|
47
|
-
thor
|
data/bin/smog
CHANGED
data/features/smog.feature
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
Feature:
|
2
|
-
In order to
|
1
|
+
Feature: Smog
|
2
|
+
In order to test that an API respects 304s
|
3
3
|
As a user
|
4
|
-
I want to
|
4
|
+
I want to query an API
|
5
5
|
|
6
6
|
Scenario: Get items
|
7
|
-
When I run
|
8
|
-
Then the output should contain exactly:
|
7
|
+
When I run the command:
|
9
8
|
"""
|
10
|
-
|
11
|
-
|
9
|
+
smog auth=test@example.com:pass "http://my.cloudapp.local/items?page=1&per_page=5"
|
12
10
|
"""
|
11
|
+
#Then the output should be exactly:
|
12
|
+
#"""
|
13
|
+
#curl -I -s --digest -u test@example.com:pass -H "Accept: application/json" "http://my.cloudapp.local/items?page=1&per_page=5"
|
14
|
+
#HTTP/1.1 401 Authorization Required
|
15
|
+
#HTTP/1.1 200 OK
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
#curl -I -s --digest -u test@example.com:pass -H "Accept: application/json" -H "If-None-Match: \"c6b5d4a0589c53bf1d8326422fc33f57\"" -H "If-Modified-Since: Fri, 15 Oct 2010 14:46:14 GMT"
|
18
|
+
#HTTP/1.1 401 Authorization Required
|
19
|
+
#HTTP/1.1 304 Not Modified
|
20
|
+
#"""
|
21
|
+
Then the output should contain:
|
17
22
|
"""
|
18
|
-
curl -I -
|
19
|
-
|
23
|
+
curl -I -s --digest -u test@example.com:pass -H "Accept: application/json" "http://my.cloudapp.local/items?page=1&per_page=5"
|
24
|
+
HTTP/1.1 401 Authorization Required
|
25
|
+
HTTP/1.1 200 OK
|
20
26
|
"""
|
21
|
-
|
22
|
-
Scenario: Get items with last-modified
|
23
|
-
When I run "smog curl --last-modified \"Tue, 05 Oct 2010 13:44:39 GMT\""
|
24
|
-
Then the output should contain exactly:
|
27
|
+
And the output should match:
|
25
28
|
"""
|
26
|
-
curl -I -
|
27
|
-
|
29
|
+
curl -I -s --digest -u test@example.com:pass -H "Accept: application/json" -H "If-None-Match: \\"[^"]+\\"" -H "If-Modified-Since: [\w,: ]+" "http://my.cloudapp.local/items\?page=1&per_page=5"
|
30
|
+
HTTP/1.1 401 Authorization Required
|
31
|
+
HTTP/1.1 304 Not Modified
|
28
32
|
"""
|
data/features/support/setup.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require(:default, :development)
|
data/lib/smog/cli.rb
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'main'
|
2
|
+
|
3
|
+
Main do
|
4
|
+
version Smog::VERSION
|
5
|
+
|
6
|
+
argument 'url' do
|
7
|
+
description 'url to query'
|
8
|
+
end
|
9
|
+
|
10
|
+
keyword 'auth' do
|
11
|
+
required
|
12
|
+
description 'digest auth credentials'
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
2.times do
|
17
|
+
command = build_curl
|
18
|
+
|
19
|
+
@last_response = %x(#{ command })
|
20
|
+
puts_response command, @last_response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
3
25
|
|
4
|
-
module Smog
|
5
|
-
class CLI < Thor
|
6
26
|
# Basic curl command:
|
7
27
|
# curl
|
8
28
|
# --digest -u "test@example.com:pass"
|
@@ -10,41 +30,50 @@ module Smog
|
|
10
30
|
# -H "If-None-Match: \"05122c59185e3bcf8b9a1976d46c2040\""
|
11
31
|
# -H "If-Modified-Since: Tue, 05 Oct 2010 13:44:39 GMT"
|
12
32
|
# "http://my.cloudapp.local/items?page=1&per_page=5"
|
33
|
+
def build_curl
|
34
|
+
[ 'curl -I -s',
|
35
|
+
"--digest -u #{ params[:auth].value }",
|
36
|
+
header('Accept', 'application/json')
|
37
|
+
].tap do |command|
|
38
|
+
if etag
|
39
|
+
command << header('If-None-Match', %{\\"#{ etag }\\"})
|
40
|
+
end
|
13
41
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
42
|
+
if last_modified
|
43
|
+
command << header('If-Modified-Since', last_modified)
|
44
|
+
end
|
45
|
+
|
46
|
+
command << params[:url].value.inspect
|
47
|
+
end.join ' '
|
20
48
|
end
|
21
49
|
|
22
|
-
|
50
|
+
def header(name, value)
|
51
|
+
%{-H "#{ name }: #{ value }"}
|
52
|
+
end
|
23
53
|
|
24
|
-
|
25
|
-
|
26
|
-
|
54
|
+
def etag
|
55
|
+
response_header /ETag: "(.*)"/
|
56
|
+
end
|
27
57
|
|
28
|
-
|
29
|
-
|
30
|
-
|
58
|
+
def last_modified
|
59
|
+
response_header /Last-Modified: (.*)/
|
60
|
+
end
|
31
61
|
|
32
|
-
|
33
|
-
|
34
|
-
end
|
62
|
+
def response_header(match_header)
|
63
|
+
return unless @last_response
|
35
64
|
|
36
|
-
|
37
|
-
|
38
|
-
end.join ' '
|
39
|
-
end
|
65
|
+
@last_response.match(match_header)[1].chomp
|
66
|
+
end
|
40
67
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
68
|
+
def puts_response(command, full_response)
|
69
|
+
puts command
|
44
70
|
|
45
|
-
|
46
|
-
|
71
|
+
full_response.split("\r\n\r\n").each do |response|
|
72
|
+
status = response.split("\r\n").first
|
73
|
+
puts " #{ status }"
|
47
74
|
end
|
48
75
|
|
49
|
-
|
76
|
+
puts
|
77
|
+
end
|
78
|
+
|
50
79
|
end
|
data/lib/smog/version.rb
CHANGED
data/smog.gemspec
CHANGED
@@ -12,17 +12,14 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{Test the CloudApp API from the command line}
|
13
13
|
s.description = %q{Smog simply outputs a curl command to use to test the CloudApp API}
|
14
14
|
|
15
|
-
s.
|
16
|
-
|
17
|
-
s.add_dependency "thor"
|
15
|
+
s.add_dependency "main"
|
18
16
|
|
19
17
|
s.add_development_dependency "rspec"
|
20
18
|
s.add_development_dependency "cucumber"
|
21
19
|
s.add_development_dependency "aruba"
|
22
20
|
|
23
|
-
s.files
|
24
|
-
s.test_files
|
25
|
-
s.executables
|
26
|
-
s.
|
27
|
-
s.require_paths = ["lib"]
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
28
25
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Larry Marburger
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
19
|
-
default_executable:
|
18
|
+
date: 2010-10-21 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: main
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- Rakefile
|
91
91
|
- bin/smog
|
92
92
|
- features/smog.feature
|
93
|
+
- features/step_definitions/command_steps.rb
|
93
94
|
- features/support/setup.rb
|
94
95
|
- lib/smog.rb
|
95
96
|
- lib/smog/cli.rb
|
@@ -118,12 +119,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
requirements:
|
119
120
|
- - ">="
|
120
121
|
- !ruby/object:Gem::Version
|
121
|
-
hash:
|
122
|
+
hash: 3
|
122
123
|
segments:
|
123
|
-
-
|
124
|
-
|
125
|
-
- 6
|
126
|
-
version: 1.3.6
|
124
|
+
- 0
|
125
|
+
version: "0"
|
127
126
|
requirements: []
|
128
127
|
|
129
128
|
rubyforge_project:
|
@@ -133,4 +132,5 @@ specification_version: 3
|
|
133
132
|
summary: Test the CloudApp API from the command line
|
134
133
|
test_files:
|
135
134
|
- features/smog.feature
|
135
|
+
- features/step_definitions/command_steps.rb
|
136
136
|
- features/support/setup.rb
|