skles 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +15 -6
- data/VERSION +1 -1
- data/lib/skles.rb +19 -14
- data/skles.gemspec +5 -2
- data/spec/skles_api_spec.rb +6 -6
- data/spec/skles_spec.rb +12 -18
- metadata +22 -9
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,26 +2,34 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
RedCloth (4.2.3)
|
5
|
-
builder (
|
5
|
+
builder (2.1.2)
|
6
6
|
crack (0.1.8)
|
7
7
|
diff-lcs (1.1.2)
|
8
8
|
git (1.2.5)
|
9
|
-
|
9
|
+
gyoku (0.1.0)
|
10
|
+
builder (~> 2.1.2)
|
11
|
+
httpclient (2.1.6)
|
12
|
+
httpi (0.7.4)
|
13
|
+
rack
|
14
|
+
jeweler (1.5.2)
|
10
15
|
bundler (~> 1.0.0)
|
11
16
|
git (>= 1.2.5)
|
12
17
|
rake
|
18
|
+
rack (1.2.1)
|
13
19
|
rake (0.8.7)
|
14
20
|
rspec (2.3.0)
|
15
21
|
rspec-core (~> 2.3.0)
|
16
22
|
rspec-expectations (~> 2.3.0)
|
17
23
|
rspec-mocks (~> 2.3.0)
|
18
|
-
rspec-core (2.3.
|
24
|
+
rspec-core (2.3.1)
|
19
25
|
rspec-expectations (2.3.0)
|
20
26
|
diff-lcs (~> 1.1.2)
|
21
27
|
rspec-mocks (2.3.0)
|
22
|
-
savon (0.
|
23
|
-
builder (
|
24
|
-
crack (
|
28
|
+
savon (0.8.0)
|
29
|
+
builder (~> 2.1.2)
|
30
|
+
crack (~> 0.1.8)
|
31
|
+
gyoku (>= 0.1.0)
|
32
|
+
httpi (>= 0.7.4)
|
25
33
|
yard (0.6.3)
|
26
34
|
|
27
35
|
PLATFORMS
|
@@ -29,6 +37,7 @@ PLATFORMS
|
|
29
37
|
|
30
38
|
DEPENDENCIES
|
31
39
|
RedCloth
|
40
|
+
httpclient
|
32
41
|
jeweler
|
33
42
|
rspec
|
34
43
|
savon
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/skles.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'savon'
|
2
2
|
require File.dirname(__FILE__) + '/skles_api'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# We have our own error raising
|
7
|
-
|
4
|
+
Savon.configure do |config|
|
5
|
+
config.log = false # can't have plaintext CC #s being logged
|
6
|
+
config.raise_errors = false # We have our own error raising
|
7
|
+
end
|
8
8
|
|
9
9
|
# Client for the StrongKey Lite Encryption System (SKLES) SOAP-based API. An
|
10
10
|
# instance of this API interfaces with your StrongKey Lite box to encrypt and
|
@@ -41,13 +41,18 @@ class StrongKeyLite
|
|
41
41
|
# @option options [String] :login You can provide the login of a user who will
|
42
42
|
# be used for all actions.
|
43
43
|
# @option options [String] :password The password for this user.
|
44
|
-
# @
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
44
|
+
# @yield [http] HTTP configuration block.
|
45
|
+
# @yieldparam [HTTPI::Request] http The HTTP request object, for configuring.
|
46
|
+
# See the HTTPI gem documentation for more information.
|
47
|
+
#
|
48
|
+
# @example Setting a custom timeout
|
49
|
+
# StrongKeyLite.new(url, domain) { |http| http.read_timeout = 60 }
|
48
50
|
|
49
51
|
def initialize(service_url, domain_id, options={})
|
50
|
-
@client = Savon::Client.new
|
52
|
+
@client = Savon::Client.new do |wsdl, http, wsse|
|
53
|
+
wsdl.document = "#{service_url}/strongkeyliteWAR/EncryptionService?wsdl"
|
54
|
+
yield http if block_given?
|
55
|
+
end
|
51
56
|
options[:http].each { |key, val| @client.request.http.send :"#{key}=", val } if options[:http].kind_of?(Hash)
|
52
57
|
|
53
58
|
self.domain_id = domain_id
|
@@ -123,7 +128,7 @@ class StrongKeyLite
|
|
123
128
|
raise "No user has been assigned to action #{meth.inspect}" unless login
|
124
129
|
password = @users[login]
|
125
130
|
|
126
|
-
response = @client.
|
131
|
+
response = @client.request(:wsdl, meth) { |soap| soap.body = { did: domain_id, username: login, password: password }.merge(options) }
|
127
132
|
raise SOAPError.new(response.soap_fault, response) if response.soap_fault?
|
128
133
|
raise HTTPError.new(response.http_error, response) if response.http_error?
|
129
134
|
|
@@ -138,8 +143,8 @@ class StrongKeyLite
|
|
138
143
|
attr_reader :response
|
139
144
|
|
140
145
|
# @private
|
141
|
-
def initialize(
|
142
|
-
super
|
146
|
+
def initialize(error, response)
|
147
|
+
super error.to_s
|
143
148
|
@response = response
|
144
149
|
end
|
145
150
|
end
|
@@ -150,9 +155,9 @@ class StrongKeyLite
|
|
150
155
|
attr_reader :code
|
151
156
|
|
152
157
|
# @private
|
153
|
-
def initialize(
|
158
|
+
def initialize(fault, response)
|
154
159
|
super
|
155
|
-
if code_match =
|
160
|
+
if code_match = fault.to_s.match(/SKL-ERR-(\d+)/) then
|
156
161
|
@code = code_match[1].try(:to_i)
|
157
162
|
end
|
158
163
|
end
|
data/skles.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{skles}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tim Morgan"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-21}
|
13
13
|
s.description = %q{A Ruby wrapper around the StrongKey Lite SOAP client API.}
|
14
14
|
s.email = %q{git@timothymorgan.info}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -48,12 +48,14 @@ Gem::Specification.new do |s|
|
|
48
48
|
s.specification_version = 3
|
49
49
|
|
50
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<httpclient>, [">= 0"])
|
51
52
|
s.add_runtime_dependency(%q<savon>, [">= 0"])
|
52
53
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
53
54
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
54
55
|
s.add_development_dependency(%q<RedCloth>, [">= 0"])
|
55
56
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
56
57
|
else
|
58
|
+
s.add_dependency(%q<httpclient>, [">= 0"])
|
57
59
|
s.add_dependency(%q<savon>, [">= 0"])
|
58
60
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
59
61
|
s.add_dependency(%q<yard>, [">= 0"])
|
@@ -61,6 +63,7 @@ Gem::Specification.new do |s|
|
|
61
63
|
s.add_dependency(%q<rspec>, [">= 0"])
|
62
64
|
end
|
63
65
|
else
|
66
|
+
s.add_dependency(%q<httpclient>, [">= 0"])
|
64
67
|
s.add_dependency(%q<savon>, [">= 0"])
|
65
68
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
66
69
|
s.add_dependency(%q<yard>, [">= 0"])
|
data/spec/skles_api_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe StrongKeyLite::API do
|
|
12
12
|
before :each do
|
13
13
|
@time = mock('Time')
|
14
14
|
Time.stub!(:parse).and_return(@time)
|
15
|
-
@client.should_receive(:
|
15
|
+
@client.should_receive(:request).once.with(:wsdl, :ping).and_return(@response)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should parse the ping response" do
|
@@ -76,8 +76,8 @@ SKLES Domain 21 is alive!
|
|
76
76
|
@response.stub(:to_hash).and_return(encrypt_response: { return: '123456' })
|
77
77
|
soap = mock('Savon::SOAP')
|
78
78
|
soap.should_receive(:body=).once.with(hash_including(plaintext: 'plaintext'))
|
79
|
-
|
80
|
-
@client.should_receive(:
|
79
|
+
|
80
|
+
@client.should_receive(:request).once.with(:wsdl, :encrypt).and_yield(soap).and_return(@response)
|
81
81
|
|
82
82
|
@skles.encrypt('plaintext').should eql('123456')
|
83
83
|
end
|
@@ -92,7 +92,7 @@ SKLES Domain 21 is alive!
|
|
92
92
|
soap = mock('Savon::SOAP')
|
93
93
|
soap.should_receive(:body=).once.with(hash_including(token: '123456'))
|
94
94
|
|
95
|
-
@client.should_receive(:
|
95
|
+
@client.should_receive(:request).once.with(:wsdl, :decrypt).and_yield(soap).and_return(@response)
|
96
96
|
|
97
97
|
@skles.decrypt('123456').should eql('plaintext')
|
98
98
|
end
|
@@ -107,7 +107,7 @@ SKLES Domain 21 is alive!
|
|
107
107
|
soap = mock('Savon::SOAP')
|
108
108
|
soap.should_receive(:body=).once.with(hash_including(token: '123456'))
|
109
109
|
|
110
|
-
@client.should_receive(:
|
110
|
+
@client.should_receive(:request).once.with(:wsdl, :delete).and_yield(soap).and_return(@response)
|
111
111
|
|
112
112
|
@skles.delete('123456').should be_true
|
113
113
|
end
|
@@ -122,7 +122,7 @@ SKLES Domain 21 is alive!
|
|
122
122
|
soap = mock('Savon::SOAP')
|
123
123
|
soap.should_receive(:body=).once.with(hash_including(plaintext: 'plaintext'))
|
124
124
|
|
125
|
-
@client.should_receive(:
|
125
|
+
@client.should_receive(:request).once.with(:wsdl, :search).and_yield(soap).and_return(@response)
|
126
126
|
|
127
127
|
@skles.search('plaintext').should eql('123456')
|
128
128
|
end
|
data/spec/skles_spec.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe StrongKeyLite do
|
4
|
-
before :each do
|
5
|
-
@client = mock('Savon::Client', request: nil)
|
6
|
-
Savon::Client.stub!(:new).and_return(@client)
|
7
|
-
end
|
8
|
-
|
9
4
|
describe "#initialize" do
|
10
5
|
it "should accept a host for the WSDL" do
|
11
|
-
|
12
|
-
StrongKeyLite.new('http://test.host', 1)
|
6
|
+
StrongKeyLite.new('http://test.host', 1).instance_variable_get(:@client).wsdl.instance_variable_get(:@document).should eql("http://test.host/strongkeyliteWAR/EncryptionService?wsdl")
|
13
7
|
end
|
14
8
|
|
15
9
|
it "should set the domain ID" do
|
@@ -17,12 +11,7 @@ describe StrongKeyLite do
|
|
17
11
|
end
|
18
12
|
|
19
13
|
it "should accept and apply HTTP options" do
|
20
|
-
http =
|
21
|
-
request = mock('Savon::Request', http: http)
|
22
|
-
@client.stub!(:request).and_return(request)
|
23
|
-
|
24
|
-
http.should_receive(:timeout=).once.with(60)
|
25
|
-
StrongKeyLite.new('http://test.host', 1, http: { timeout: 60 })
|
14
|
+
StrongKeyLite.new('http://test.host', 1) { |http| http.read_timeout = 60 }.instance_variable_get(:@client).http.read_timeout.should eql(60)
|
26
15
|
end
|
27
16
|
|
28
17
|
it "should optionally accept a login and password" do
|
@@ -31,6 +20,11 @@ describe StrongKeyLite do
|
|
31
20
|
end
|
32
21
|
|
33
22
|
describe "#call" do
|
23
|
+
before :each do
|
24
|
+
@client = mock('Savon::Client', request: nil)
|
25
|
+
Savon::Client.stub!(:new).and_return(@client)
|
26
|
+
end
|
27
|
+
|
34
28
|
before :each do
|
35
29
|
@client = mock('Savon::Client', request: nil, wsdl: mock('Savon::WSDL', soap_actions: [ :ping ]))
|
36
30
|
Savon::Client.stub!(:new).and_return(@client)
|
@@ -49,7 +43,7 @@ describe StrongKeyLite do
|
|
49
43
|
|
50
44
|
soap = mock('Savon::Request')
|
51
45
|
soap.should_receive(:body=).once.with({ did: 1, username: 'login', password: 'password' })
|
52
|
-
@client.should_receive(:
|
46
|
+
@client.should_receive(:request).once.with(:wsdl, :ping).and_yield(soap).and_return(@response)
|
53
47
|
@skles.ping
|
54
48
|
end
|
55
49
|
|
@@ -58,7 +52,7 @@ describe StrongKeyLite do
|
|
58
52
|
|
59
53
|
soap = mock('Savon::Request')
|
60
54
|
soap.should_receive(:body=).once.with({ did: 1, username: 'all', password: 'password' })
|
61
|
-
@client.should_receive(:
|
55
|
+
@client.should_receive(:request).once.with(:wsdl, :ping).and_yield(soap).and_return(@response)
|
62
56
|
@skles.ping
|
63
57
|
end
|
64
58
|
|
@@ -68,7 +62,7 @@ describe StrongKeyLite do
|
|
68
62
|
|
69
63
|
soap = mock('Savon::Request')
|
70
64
|
soap.should_receive(:body=).once.with({ did: 1, username: 'ping', password: 'password' })
|
71
|
-
@client.should_receive(:
|
65
|
+
@client.should_receive(:request).once.with(:wsdl, :ping).and_yield(soap).and_return(@response)
|
72
66
|
@skles.ping
|
73
67
|
end
|
74
68
|
|
@@ -76,7 +70,7 @@ describe StrongKeyLite do
|
|
76
70
|
@skles.add_user('all', 'password', :all)
|
77
71
|
soap = mock('Savon::Request')
|
78
72
|
soap.stub!(:body=)
|
79
|
-
@client.stub!(:
|
73
|
+
@client.stub!(:request).and_yield(soap).and_return(@response)
|
80
74
|
@response.stub!(:http_error?).and_return(true)
|
81
75
|
@response.stub!(:http_error).and_return("404 Not Found")
|
82
76
|
|
@@ -87,7 +81,7 @@ describe StrongKeyLite do
|
|
87
81
|
@skles.add_user('all', 'password', :all)
|
88
82
|
soap = mock('Savon::Request')
|
89
83
|
soap.stub!(:body=)
|
90
|
-
@client.stub!(:
|
84
|
+
@client.stub!(:request).and_yield(soap).and_return(@response)
|
91
85
|
@response.stub!(:soap_fault?).and_return(true)
|
92
86
|
@response.stub!(:soap_fault).and_return("Not enough XML")
|
93
87
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 3
|
9
|
+
version: 1.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tim Morgan
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-21 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: httpclient
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
prerelease: false
|
32
32
|
version_requirements: *id001
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: savon
|
35
35
|
requirement: &id002 !ruby/object:Gem::Requirement
|
36
36
|
none: false
|
37
37
|
requirements:
|
@@ -40,11 +40,11 @@ dependencies:
|
|
40
40
|
segments:
|
41
41
|
- 0
|
42
42
|
version: "0"
|
43
|
-
type: :
|
43
|
+
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: *id002
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: jeweler
|
48
48
|
requirement: &id003 !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: *id003
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
60
|
+
name: yard
|
61
61
|
requirement: &id004 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
@@ -70,7 +70,7 @@ dependencies:
|
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: *id004
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
73
|
+
name: RedCloth
|
74
74
|
requirement: &id005 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
@@ -82,6 +82,19 @@ dependencies:
|
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: *id005
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rspec
|
87
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: *id006
|
85
98
|
description: A Ruby wrapper around the StrongKey Lite SOAP client API.
|
86
99
|
email: git@timothymorgan.info
|
87
100
|
executables: []
|