crowd 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
- == 0.5.2 / 2007-10-24
1
+ == 0.5.3 / 2007-10-24
2
2
 
3
+ * 0.5.3
4
+ * Added is_valid_principal_token?
3
5
  * 0.5.2
4
6
  * Fixed an uncaught exception when finding a user by an expired token.
5
7
  * 0.5.1
data/README.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  = crowd
2
- by Jason Rimmer (jrimmer@irth.net) & gemified by Daniel Morrison (http://collectiveidea.com)
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
 
@@ -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
@@ -2,7 +2,7 @@ class Crowd #:nodoc:
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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.2
7
- date: 2007-11-02 00:00:00 -04:00
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