crowd 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # Created by Jason Rimmer, jrimmer@irth.net on 2007-10-16.
5
+ # I hereby place this work that I have authored into the public domain
6
+ # and in the process abandon all copyright protection.
7
+ #
8
+
9
+ require 'test/unit'
10
+ require 'test/unit/ui/console/testrunner'
11
+
12
+ require 'rubygems'
13
+ gem 'soap4r'
14
+ require 'active_support'
15
+
16
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'crowd')
17
+
18
+ # Add extra methods to Crowd for testing
19
+ class Crowd
20
+ cattr_accessor :application_token
21
+ end
22
+
23
+
24
+ #
25
+ # Unfortunately tests currently need to be run in to the order given
26
+ # as there are dependencies
27
+ #
28
+ # Numbers after 'test' in method names force the order
29
+ #
30
+ #
31
+
32
+ class TestCrowd < Test::Unit::TestCase
33
+ def setup
34
+ Crowd.crowd_url = 'http://127.0.0.1:8095/crowd/services/SecurityServer'
35
+ Crowd.crowd_app_name = 'soaptest'
36
+ Crowd.crowd_app_pword = 'soaptest'
37
+ end
38
+
39
+ def test_A_get_app_auth_token
40
+ token = Crowd.authenticate_application
41
+
42
+ assert(!token.nil?)
43
+ end
44
+
45
+ def test_B_add_principal
46
+ token = Crowd.authenticate_application
47
+
48
+ result = Crowd.add_principal('unittest', 'unittest', 'unit test user', true, { 'mail' => 'unittest@unittest.com'})
49
+
50
+ assert(!result.nil?)
51
+ end
52
+
53
+ def test_C_find_valid_principal_byname
54
+ token = Crowd.authenticate_application
55
+
56
+ result = Crowd.find_principal_by_username('unittest')
57
+
58
+ assert !result.nil? && result.size > 0
59
+ end
60
+
61
+ def test_D_find_invalid_principal_byname
62
+ token = Crowd.authenticate_application
63
+
64
+ assert_raise Crowd::AuthenticationObjectNotFoundException do
65
+ Crowd.find_principal_by_username('asfasdasdasdas')
66
+ end
67
+ end
68
+
69
+ def test_E_add_attribute_principal
70
+ token = Crowd.authenticate_application
71
+
72
+ attrs = { 'scalar' => 'value', 'array' => ['1', '2', '3'] }
73
+
74
+ result = Crowd.add_attribute_principal('unittest', attrs)
75
+
76
+ assert(result)
77
+ end
78
+
79
+ def test_F_update_attribute_principal
80
+ token = Crowd.authenticate_application
81
+
82
+ attrs = { 'scalar' => 'value!', 'array' => ['4', '5', '6'] }
83
+
84
+ result = Crowd.update_attribute_principal('unittest', attrs)
85
+
86
+ assert(result)
87
+ end
88
+
89
+ def test_G_remove_attribute_principal
90
+ token = Crowd.authenticate_application
91
+
92
+ attrs = ['scalar', 'array']
93
+
94
+ result = Crowd.remove_attribute_principal('unittest', attrs)
95
+
96
+ assert(result)
97
+ end
98
+
99
+ def test_H_find_all_principal_names
100
+ token = Crowd.authenticate_application
101
+
102
+ result = Crowd.find_all_principal_names
103
+
104
+ assert(result)
105
+ end
106
+
107
+ def test_I_add_role
108
+ token = Crowd.authenticate_application
109
+ result = Crowd.add_role('test_role', 'unit test role', true)
110
+ assert(result)
111
+ end
112
+
113
+ def test_J_find_all_role_names
114
+ token = Crowd.authenticate_application
115
+ result = Crowd.find_all_role_names
116
+
117
+ assert(result)
118
+ end
119
+
120
+ def test_K_add_principal_to_role
121
+ token = Crowd.authenticate_application
122
+ result = Crowd.add_principal_to_role('unittest', 'test_role')
123
+
124
+ assert(result)
125
+ end
126
+
127
+ def test_L_remove_principal_from_role
128
+ token = Crowd.authenticate_application
129
+ result = Crowd.remove_principal_from_role('unittest', 'test_role')
130
+
131
+ assert(result)
132
+ end
133
+
134
+ def test_M_remove_role
135
+ token = Crowd.authenticate_application
136
+ result = Crowd.remove_role('test_role')
137
+
138
+ assert(result)
139
+ end
140
+
141
+ def test_N_remove_principal
142
+ token = Crowd.authenticate_application
143
+ result = Crowd.remove_principal('unittest')
144
+
145
+ assert(result)
146
+ end
147
+
148
+ def test_C_expired_application_token_gets_reset
149
+ token = Crowd.authenticate_application
150
+ # Overwrite the token
151
+ Crowd.application_token.token = 'fake'
152
+ assert_equal 'fake', Crowd.application_token.token
153
+
154
+ # Make a request
155
+ result = Crowd.find_principal_by_username('unittest')
156
+
157
+ assert_not_equal 'fake', Crowd.application_token.token
158
+ end
159
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: crowd
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.5.0
7
+ date: 2007-10-21 00:00:00 -04:00
8
+ summary: Ruby client for Atlassian Crowd
9
+ require_paths:
10
+ - lib
11
+ email: jrimmer@irth.net
12
+ homepage: http://crowd.rubyforge.org
13
+ rubyforge_project: crowd
14
+ description: "A client for Atlassian Crowd v1.1.0r2. Notes: WSDL stub generated with wsdl2ruby.rb --wsdl http://localhost:8095/crowd/services/SecurityServer?wsdl --type client Files: default.rb - Generated defaultDriver.rb - Generated defaultMappingRegistry - Generated README - You're soaking in it SecurityServerClient.rb - Generated crowd.rb - Class wrapping crowd calls test_crowd.rb - Unit tests == FEATURES: Methods exercised: authenticatePrincipal addPrincipal findPrincipalByName findPrincipalByToken removeAttributeFromPrincipal addAttributeToPrincipal updatePrincipalAttribute removePrincipal findAllPrincipalNames findAllRoleNames addRole addPrincipalToRole removePrincipalFromRole isRoleMember removeRole"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Jason Rimmer & Daniel Morrison
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - lib/SecurityServerClient.rb
37
+ - lib/crowd-1.1.0.wsdl
38
+ - lib/crowd.rb
39
+ - lib/crowd/version.rb
40
+ - lib/default.rb
41
+ - lib/defaultDriver.rb
42
+ - lib/defaultMappingRegistry.rb
43
+ - test/test_crowd.rb
44
+ test_files:
45
+ - test/test_crowd.rb
46
+ rdoc_options:
47
+ - --main
48
+ - README.txt
49
+ extra_rdoc_files:
50
+ - History.txt
51
+ - Manifest.txt
52
+ - README.txt
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ requirements: []
58
+
59
+ dependencies:
60
+ - !ruby/object:Gem::Dependency
61
+ name: soap4r
62
+ version_requirement:
63
+ version_requirements: !ruby/object:Gem::Version::Requirement
64
+ requirements:
65
+ - - ">"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.0.0
68
+ version:
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe
71
+ version_requirement:
72
+ version_requirements: !ruby/object:Gem::Version::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.3.0
77
+ version: