sunspot4r 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +3 -0
- data/README.markdown +21 -0
- data/Rakefile +55 -0
- data/Sunspot4R.gemspec +69 -0
- data/VERSION +1 -0
- data/lib/ext/savon/request.rb +27 -0
- data/lib/sunspot4r.rb +23 -0
- data/lib/sunspot4r/base_sunspot_service_client.rb +77 -0
- data/lib/sunspot4r/object_service_client.rb +145 -0
- data/lib/sunspot4r/security_service_client.rb +432 -0
- data/lib/sunspot4r/system_service_client.rb +184 -0
- data/test/config.yml +9 -0
- data/test/object_service_client_test.rb +84 -0
- data/test/security_service_client_test.rb +64 -0
- data/test/system_service_client_test.rb +40 -0
- data/test/test_helper.rb +10 -0
- data/test/test_suite.rb +3 -0
- metadata +120 -0
data/test/config.yml
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ObjectServiceClientTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "An ObjectServiceClient instance with a Console user session" do
|
6
|
+
setup do
|
7
|
+
# Get the base url using the SystemService
|
8
|
+
system_service_client = Sunspot4R::SystemServiceClient.new
|
9
|
+
result = system_service_client.get_sunspot_uri(CONFIG['association_guid'])
|
10
|
+
base_url = result[:uri]
|
11
|
+
|
12
|
+
# Log in using the SecurityService & get a session guid
|
13
|
+
security_service_client = Sunspot4R::SecurityServiceClient.new(base_url)
|
14
|
+
result = security_service_client.console_login(CONFIG['console']['username'], CONFIG['console']['password'])
|
15
|
+
session_guid = result[:session_guid]
|
16
|
+
|
17
|
+
@object_service_client = Sunspot4R::ObjectServiceClient.new(base_url, {
|
18
|
+
:session_guid => session_guid
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
should "return all Product objects available to the user" do
|
23
|
+
response = @object_service_client.available_objects(CONFIG['association_guid'], 'Product')
|
24
|
+
assert response[:success]
|
25
|
+
end
|
26
|
+
|
27
|
+
should "return a single object instance from a GUID" do
|
28
|
+
# API Individual GUID - TODO make it a CONFIG variable
|
29
|
+
response = @object_service_client.query_by_guid('006287e7-4fdf-4ab0-8e7a-af33c0e03d17')
|
30
|
+
assert response[:success]
|
31
|
+
end
|
32
|
+
|
33
|
+
should "return all RelationshipTypes using :get_all" do
|
34
|
+
response = @object_service_client.get_all(CONFIG['association_guid'], 'RelationshipType')
|
35
|
+
assert response[:success]
|
36
|
+
end
|
37
|
+
|
38
|
+
should "return 50 Individual results using :query" do
|
39
|
+
response = @object_service_client.query(CONFIG['association_guid'],
|
40
|
+
'from PortalUser ind Order By ind.CreatedDate', 0, 5)
|
41
|
+
|
42
|
+
# TODO: Figure out Nokogiri
|
43
|
+
# doc = Nokogiri::XML(response)
|
44
|
+
# #pp doc.collect_namespaces
|
45
|
+
# pp doc.xpath('//a:Success', 'a' => 'http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API.Results').text
|
46
|
+
#
|
47
|
+
# objects = doc.xpath('//b:anyType', 'b' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays')
|
48
|
+
# puts objects.count
|
49
|
+
# pp objects[0].xpath('//Key')
|
50
|
+
# ## pp objects[0].xpath('/c:Fields/b:KeyValueOfstringanyType[Key="JobTitle"]/text()',
|
51
|
+
# 'b' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays')
|
52
|
+
#
|
53
|
+
# ## pp doc.css('a:Success')
|
54
|
+
# #assert response[:success]
|
55
|
+
|
56
|
+
|
57
|
+
# Just use response +to_hash+ for now even though performance will suck.
|
58
|
+
|
59
|
+
# We'll pull out the data we need from the response and put it into this
|
60
|
+
# individuals array.
|
61
|
+
individuals = []
|
62
|
+
|
63
|
+
for individual_data in response[:objects][:any_type]
|
64
|
+
|
65
|
+
# Hash to hold the cleaned individual data
|
66
|
+
individual = {}
|
67
|
+
|
68
|
+
individual_data[:fields][:key_value_ofstringany_type].each do |data|
|
69
|
+
if data[:value].is_a?(Hash) && data[:value][:nil]
|
70
|
+
individual[data[:key]] = ''
|
71
|
+
else
|
72
|
+
individual[data[:key]] = data[:value]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
individuals << individual
|
77
|
+
end
|
78
|
+
|
79
|
+
pp individuals[0]
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SecurityServiceClientTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A SecurityServiceClient instance without a session identifier" do
|
6
|
+
setup do
|
7
|
+
system_service_client = Sunspot4R::SystemServiceClient.new
|
8
|
+
result = system_service_client.get_sunspot_uri(CONFIG['association_guid'])
|
9
|
+
@base_url = result[:uri]
|
10
|
+
|
11
|
+
@security_service_client = Sunspot4R::SecurityServiceClient.new(@base_url)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "respond to :console_login" do
|
15
|
+
assert_respond_to @security_service_client, :console_login
|
16
|
+
end
|
17
|
+
|
18
|
+
# :console_login tests
|
19
|
+
context "call to :console_login with a valid username & password" do
|
20
|
+
setup do
|
21
|
+
@console_login_result = @security_service_client.console_login(CONFIG['console']['username'], CONFIG['console']['password'])
|
22
|
+
end
|
23
|
+
|
24
|
+
should "return true for the success property" do
|
25
|
+
assert @console_login_result[:success]
|
26
|
+
end
|
27
|
+
|
28
|
+
should "return a session guid" do
|
29
|
+
assert @console_login_result[:session_guid]
|
30
|
+
end
|
31
|
+
|
32
|
+
should "return the user type" do
|
33
|
+
assert @console_login_result[:user][:type]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "call to :console_login with a bad username & password" do
|
38
|
+
setup do
|
39
|
+
@console_login_result = @security_service_client.console_login('bad_username', 'bad_password')
|
40
|
+
end
|
41
|
+
|
42
|
+
should "return false for the success property" do
|
43
|
+
assert !@console_login_result[:success]
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return nil for the session guid" do
|
47
|
+
assert_equal({ :nil => true }, @console_login_result[:session_guid])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# :portal_login tests
|
53
|
+
context "call to :portal_login with a valid username & password" do
|
54
|
+
setup do
|
55
|
+
@portal_login_result = @security_service_client.portal_login(CONFIG['association_guid'], CONFIG['portal']['username'], CONFIG['portal']['password'])
|
56
|
+
end
|
57
|
+
|
58
|
+
should "return true for the success property" do
|
59
|
+
assert @portal_login_result[:success]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SystemServiceClientTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A SystemServiceClient instance without a session" do
|
6
|
+
setup do
|
7
|
+
@system_service_client = Sunspot4R::SystemServiceClient.new
|
8
|
+
end
|
9
|
+
|
10
|
+
should "respond to :get_sunspot_uri" do
|
11
|
+
assert_respond_to @system_service_client, :get_sunspot_uri
|
12
|
+
end
|
13
|
+
|
14
|
+
should "return a sunspot uri with a valid association guid" do
|
15
|
+
response = @system_service_client.get_sunspot_uri(CONFIG['association_guid'])
|
16
|
+
assert response[:success]
|
17
|
+
# TODO match the uri better? make sure it matches
|
18
|
+
# xxxx-sunspot.connect.daxko.com
|
19
|
+
assert_match /https:/, response[:uri]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# context "A SystemServiceClient instance with a Console user session" do
|
24
|
+
# setup do
|
25
|
+
# @security_service_client = Sunspot4R::SecurityServiceClient.new
|
26
|
+
# @console_login_result = @security_service_client.console_login(CONFIG['console']['username'], CONFIG['console']['password'])
|
27
|
+
# @session_guid = @console_login_result[:session_guid]
|
28
|
+
#
|
29
|
+
# @system_service_client = Sunspot4R::SystemServiceClient.new('http://live-sunspot.connect.daxko.com/Live/Partner/SystemService?wsdl', {
|
30
|
+
# :session_guid => @session_guid
|
31
|
+
# })
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# should "return the available Customer objects for the user" do
|
35
|
+
# response = @system_service_client.get_available_customers_for_user
|
36
|
+
# assert response[:success]
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# end
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'yaml'
|
7
|
+
require 'pp'
|
8
|
+
require 'sunspot4r'
|
9
|
+
|
10
|
+
CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config.yml") unless defined? CONFIG
|
data/test/test_suite.rb
ADDED
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sunspot4r
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Tony Summerville
|
14
|
+
- Josh Dennis
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-08-04 00:00:00 -05:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: savon
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 19
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 7
|
34
|
+
- 8
|
35
|
+
version: 0.7.8
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: shoulda
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
version: "0"
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
description: Ruby wrapper for DAXKO Sunspot
|
53
|
+
email: dennijo@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files:
|
59
|
+
- LICENSE
|
60
|
+
- README
|
61
|
+
- README.markdown
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- README
|
65
|
+
- README.markdown
|
66
|
+
- Rakefile
|
67
|
+
- Sunspot4R.gemspec
|
68
|
+
- VERSION
|
69
|
+
- lib/ext/savon/request.rb
|
70
|
+
- lib/sunspot4r.rb
|
71
|
+
- lib/sunspot4r/base_sunspot_service_client.rb
|
72
|
+
- lib/sunspot4r/object_service_client.rb
|
73
|
+
- lib/sunspot4r/security_service_client.rb
|
74
|
+
- lib/sunspot4r/system_service_client.rb
|
75
|
+
- test/config.yml
|
76
|
+
- test/object_service_client_test.rb
|
77
|
+
- test/security_service_client_test.rb
|
78
|
+
- test/system_service_client_test.rb
|
79
|
+
- test/test_helper.rb
|
80
|
+
- test/test_suite.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://github.com/dennijo/sunspot4R
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options:
|
87
|
+
- --charset=UTF-8
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.3.7
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Ruby wrapper for DAXKO Sunspot
|
115
|
+
test_files:
|
116
|
+
- test/object_service_client_test.rb
|
117
|
+
- test/security_service_client_test.rb
|
118
|
+
- test/system_service_client_test.rb
|
119
|
+
- test/test_helper.rb
|
120
|
+
- test/test_suite.rb
|