crowd 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -1
- data/README.txt +2 -1
- data/lib/crowd.rb +21 -3
- data/lib/crowd/version.rb +1 -1
- data/test/test_crowd.rb +37 -0
- metadata +3 -3
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
= crowd
|
2
|
-
by Jason Rimmer (jrimmer@irth.net)
|
2
|
+
by Jason Rimmer (jrimmer@irth.net). Gemified and updated by Daniel Morrison (http://collectiveidea.com)
|
3
3
|
|
4
4
|
== DESCRIPTION:
|
5
5
|
|
@@ -28,6 +28,7 @@ Methods exercised:
|
|
28
28
|
* isRoleMember
|
29
29
|
* removeRole
|
30
30
|
* invalidatePrincipalToken
|
31
|
+
* isValidPrincipalToken
|
31
32
|
|
32
33
|
Assumptions (configured in CrowdTest.rb):
|
33
34
|
|
data/lib/crowd.rb
CHANGED
@@ -109,6 +109,22 @@ class Crowd
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
##
|
113
|
+
# Is valid principal token?
|
114
|
+
def self.is_valid_principal_token?(principal_token, validation_factors = [])
|
115
|
+
response = authenticated_connection do
|
116
|
+
arg = IsValidPrincipalToken.new(@@application_token, principal_token, validation_factors)
|
117
|
+
server.isValidPrincipalToken(arg)
|
118
|
+
end
|
119
|
+
|
120
|
+
case response
|
121
|
+
when IsValidPrincipalTokenResponse
|
122
|
+
return response.out
|
123
|
+
else
|
124
|
+
raise AuthenticationException, response
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
112
128
|
##
|
113
129
|
# Add Principal
|
114
130
|
def self.add_principal(username, password, description, is_active, attributes)
|
@@ -156,7 +172,7 @@ class Crowd
|
|
156
172
|
when FindPrincipalByNameResponse
|
157
173
|
return parse_principal(response.out)
|
158
174
|
when ObjectNotFoundException
|
159
|
-
return
|
175
|
+
return nil
|
160
176
|
else
|
161
177
|
raise AuthenticationException, response
|
162
178
|
end
|
@@ -173,10 +189,12 @@ class Crowd
|
|
173
189
|
when FindPrincipalByTokenResponse
|
174
190
|
return parse_principal(response.out)
|
175
191
|
when ObjectNotFoundException
|
176
|
-
return
|
192
|
+
return nil
|
177
193
|
else
|
178
194
|
raise AuthenticationException, response
|
179
|
-
end
|
195
|
+
end
|
196
|
+
rescue AuthenticationObjectNotFoundException
|
197
|
+
return nil
|
180
198
|
rescue SOAP::FaultError => e
|
181
199
|
raise AuthenticationException, e.message
|
182
200
|
end
|
data/lib/crowd/version.rb
CHANGED
data/test/test_crowd.rb
CHANGED
@@ -156,4 +156,41 @@ class TestCrowd < Test::Unit::TestCase
|
|
156
156
|
|
157
157
|
assert_not_equal 'fake', Crowd.application_token.token
|
158
158
|
end
|
159
|
+
|
160
|
+
def test_is_valid_principal_token_with_invalid_token
|
161
|
+
assert !Crowd.is_valid_principal_token?('invalid')
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_C_is_valid_principal_token_with_valid_token
|
165
|
+
valid_principal_token = Crowd.authenticate_principal('unittest', 'unittest')
|
166
|
+
|
167
|
+
assert Crowd.is_valid_principal_token?(valid_principal_token)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_C_is_valid_principal_token_with_previously_valid_but_invalidated_token
|
171
|
+
valid_principal_token = Crowd.authenticate_principal('unittest', 'unittest')
|
172
|
+
# Expire the token
|
173
|
+
Crowd.invalidate_principal_token(valid_principal_token)
|
174
|
+
|
175
|
+
assert !Crowd.is_valid_principal_token?(valid_principal_token)
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_C_is_valid_principal_token_with_valid_principal_token_and_invalid_application_token
|
179
|
+
valid_principal_token = Crowd.authenticate_principal('unittest', 'unittest')
|
180
|
+
# Overwrite the token
|
181
|
+
Crowd.application_token.token = 'fake'
|
182
|
+
assert_equal 'fake', Crowd.application_token.token
|
183
|
+
|
184
|
+
# token should be valid, as the application should re-authenticate.
|
185
|
+
assert Crowd.is_valid_principal_token?(valid_principal_token)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_C_find_principal_by_token_returns_nil_when_token_is_invalid
|
189
|
+
valid_principal_token = Crowd.authenticate_principal('unittest', 'unittest')
|
190
|
+
|
191
|
+
assert_not_nil Crowd.find_principal_by_token(valid_principal_token)
|
192
|
+
assert_nil Crowd.find_principal_by_token('invalid')
|
193
|
+
|
194
|
+
end
|
195
|
+
|
159
196
|
end
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: crowd
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.5.3
|
7
|
+
date: 2007-11-03 00:00:00 -04:00
|
8
8
|
summary: Ruby client for Atlassian Crowd
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: jrimmer@irth.net
|
12
12
|
homepage: http://crowd.rubyforge.org
|
13
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 == FEATURES: Methods exercised: * authenticatePrincipal * addPrincipal * findPrincipalByName * findPrincipalByToken * removeAttributeFromPrincipal * addAttributeToPrincipal * updatePrincipalAttribute * removePrincipal * findAllPrincipalNames * findAllRoleNames * addRole * addPrincipalToRole * removePrincipalFromRole * isRoleMember * removeRole * invalidatePrincipalToken"
|
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 == FEATURES: Methods exercised: * authenticatePrincipal * addPrincipal * findPrincipalByName * findPrincipalByToken * removeAttributeFromPrincipal * addAttributeToPrincipal * updatePrincipalAttribute * removePrincipal * findAllPrincipalNames * findAllRoleNames * addRole * addPrincipalToRole * removePrincipalFromRole * isRoleMember * removeRole * invalidatePrincipalToken * isValidPrincipalToken"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|