crowd-stefanwille 0.5.8

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.
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # Created by Evgeny Zislis, evgeny.zislis@gmail.com on 2008-05-15
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
+ require 'rubygems'
9
+ gem 'rspec'
10
+ gem 'soap4r'
11
+
12
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'crowd')
13
+
14
+ # need a special accessor for tests
15
+ class Crowd
16
+ def self.application_token
17
+ @@application_token
18
+ end
19
+ def self.application_token=(value)
20
+ @@application_token = value
21
+ end
22
+ end
23
+
24
+ describe Crowd do
25
+ before(:all) do
26
+ Crowd.crowd_url = 'http://127.0.0.1:8095/crowd/services/SecurityServer'
27
+ Crowd.crowd_app_name = 'soaptest'
28
+ Crowd.crowd_app_pword = 'soaptest'
29
+ end
30
+
31
+ it "should get an application authentication token" do
32
+ Crowd.authenticate_application.should_not be_nil
33
+ end
34
+
35
+ it "should add a principal" do
36
+ Crowd.add_principal('unittest','unittest','unit test user', true,
37
+ { 'mail' => 'unittest@unittest.com', 'givenName' => 'Unit', 'sn' => 'Test' }).should_not be_nil
38
+ end
39
+
40
+ it "should find valid principal by name" do
41
+ result = Crowd.find_principal_by_username('unittest')
42
+ result[:name].should eql("unittest")
43
+ end
44
+
45
+ it "should find invalid principal by name" do
46
+ lambda {
47
+ Crowd.find_principal_by_username('asfasdasdasdas')
48
+ }.should raise_error(Crowd::AuthenticationObjectNotFoundException)
49
+ end
50
+
51
+ it "should add attributes to principal" do
52
+ attributes = { 'scalar' => 'value', 'array' => ['1','2','3'] }
53
+ Crowd.add_attribute_principal('unittest', attributes).should be_true
54
+ end
55
+
56
+ it "should update attributes on principal" do
57
+ attributes = { 'scalar' => 'value!', 'array' => ['4','5','6'] }
58
+ Crowd.update_attribute_principal('unittest', attributes).should be_true
59
+ end
60
+
61
+ it "should remove attributes from principal" do
62
+ attributes = ['scalar', 'array']
63
+ Crowd.remove_attribute_principal('unittest', attributes).should eql(attributes)
64
+ end
65
+
66
+ it "should find all principle names" do
67
+ Crowd.find_all_principal_names.should include('unittest')
68
+ end
69
+
70
+ # Roles are deprecated in Crowd 2 in favor of groups
71
+ #
72
+ # it "should add role" do
73
+ # Crowd.add_role('test_role', 'unit test role', true).should be_true
74
+ # end
75
+ #
76
+ # it "should find all role names" do
77
+ # Crowd.find_all_role_names.should include('test_role')
78
+ # end
79
+ #
80
+ # it "should add principal to role" do
81
+ # Crowd.add_principal_to_role('unittest','test_role').should be_true
82
+ # end
83
+ #
84
+ # it "should remove principal from role" do
85
+ # Crowd.remove_principal_from_role('unittest', 'test_role').should be_true
86
+ # end
87
+ #
88
+ # it "should remove role" do
89
+ # Crowd.remove_role('test_role').should be_true
90
+ # end
91
+
92
+ it "should reset expired application token" do
93
+ Crowd.application_token.token = 'fake'
94
+ Crowd.application_token.token.should eql('fake')
95
+ Crowd.find_principal_by_username('unittest')
96
+ Crowd.application_token.token.should_not eql('fake')
97
+ end
98
+
99
+ it "should validate principal token with invalid token" do
100
+ Crowd.is_valid_principal_token?('invalid').should be_false
101
+ end
102
+
103
+ it "should validate principal token with valid token" do
104
+ token = Crowd.authenticate_principal('unittest','unittest')
105
+ Crowd.is_valid_principal_token?(token).should be_true
106
+ end
107
+
108
+ it "should validate principal token with valid token" do
109
+ token = Crowd.authenticate_principal('unittest','unittest')
110
+ Crowd.is_valid_principal_token?(token).should be_true
111
+ end
112
+
113
+ it "should reject principal with invalid token" do
114
+ lambda {
115
+ Crowd.authenticate_principal('unittest','bad-password')
116
+ }.should raise_error(Crowd::AuthenticationException)
117
+ end
118
+
119
+ it "should expire valid principal tokens" do
120
+ token = Crowd.authenticate_principal('unittest','unittest')
121
+ # expire the token
122
+ Crowd.invalidate_principal_token(token)
123
+ Crowd.is_valid_principal_token?(token).should be_false
124
+ end
125
+
126
+ it "should validate principal token when application token invalid" do
127
+ token = Crowd.authenticate_principal('unittest','unittest')
128
+ # overwrite application token
129
+ Crowd.application_token.token = 'fake'
130
+ Crowd.application_token.token.should eql('fake')
131
+ # application should re-authenticate
132
+ Crowd.is_valid_principal_token?(token).should be_true
133
+ end
134
+
135
+ it "should return nil when finding principal by invalid token" do
136
+ token = Crowd.authenticate_principal('unittest','unittest')
137
+ Crowd.find_principal_by_token(token).should_not be_nil
138
+ Crowd.find_principal_by_token('invalid').should be_nil
139
+ end
140
+
141
+ it "should remove principal" do
142
+ Crowd.remove_principal('unittest').should be_true
143
+ end
144
+
145
+ it "should find all groups" do
146
+ Crowd.find_all_group_names.should be_true
147
+ end
148
+
149
+ end
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{stefanwille-crowd}
8
+ s.version = "0.5.8"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Stefan Wille", "Evgeny Zislis", "Jason Rimmer & Daniel Morrison"]
12
+ s.date = %q{2010-07-14}
13
+ s.description = %q{A client for Atlassian[http://www.atlassian.com] Crowd[http://www.atlassian.com/crowd] v2.0.5}
14
+ s.email = %q{post @nospam@ stefanwille.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "demo/crowd_demo.rb",
24
+ "lib/crowd.rb",
25
+ "lib/crowd/http/request.rb",
26
+ "lib/crowd/http/response.rb",
27
+ "lib/crowd/http/sso.rb",
28
+ "lib/crowd/soap/SecurityServerClient.rb",
29
+ "lib/crowd/soap/crowd-2.0.5.wsdl",
30
+ "lib/crowd/soap/default.rb",
31
+ "lib/crowd/soap/driver.rb",
32
+ "lib/crowd/soap/mapping_registry.rb",
33
+ "lib/crowd/version.rb",
34
+ "spec/crowd_spec.rb",
35
+ "stefanwille-crowd.gemspec"
36
+ ]
37
+ s.homepage = %q{http://github.com/stefanwille/crowd}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.7}
41
+ s.summary = %q{Ruby client for Atlassian Crowd}
42
+ s.test_files = [
43
+ "spec/crowd_spec.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<soap4r>, [">= 0"])
52
+ s.add_development_dependency(%q<rspec>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<soap4r>, [">= 0"])
55
+ s.add_dependency(%q<rspec>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<soap4r>, [">= 0"])
59
+ s.add_dependency(%q<rspec>, [">= 0"])
60
+ end
61
+ end
62
+
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crowd-stefanwille
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 8
10
+ version: 0.5.8
11
+ platform: ruby
12
+ authors:
13
+ - Stefan Wille
14
+ - Evgeny Zislis
15
+ - Jason Rimmer & Daniel Morrison
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-07-14 00:00:00 +02:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: soap4r
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: A client for Atlassian[http://www.atlassian.com] Crowd[http://www.atlassian.com/crowd] v2.0.5
52
+ email: post @nospam@ stefanwille.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README.rdoc
59
+ files:
60
+ - .gitignore
61
+ - History.txt
62
+ - README.rdoc
63
+ - Rakefile
64
+ - demo/crowd_demo.rb
65
+ - lib/crowd.rb
66
+ - lib/crowd/http/request.rb
67
+ - lib/crowd/http/response.rb
68
+ - lib/crowd/http/sso.rb
69
+ - lib/crowd/soap/SecurityServerClient.rb
70
+ - lib/crowd/soap/crowd-2.0.5.wsdl
71
+ - lib/crowd/soap/default.rb
72
+ - lib/crowd/soap/driver.rb
73
+ - lib/crowd/soap/mapping_registry.rb
74
+ - lib/crowd/version.rb
75
+ - spec/crowd_spec.rb
76
+ - stefanwille-crowd.gemspec
77
+ has_rdoc: true
78
+ homepage: http://github.com/stefanwille/crowd
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --charset=UTF-8
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ requirements: []
105
+
106
+ rubyforge_project:
107
+ rubygems_version: 1.3.7
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Ruby client for Atlassian Crowd
111
+ test_files:
112
+ - spec/crowd_spec.rb