jgrouper 0.0.4 → 0.0.5
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/HISTORY.md +13 -2
- data/README.rdoc +20 -13
- data/Rakefile +1 -1
- data/TODO.md +10 -43
- data/lib/jgrouper/group/test_case.rb +18 -0
- data/lib/jgrouper/group.rb +75 -76
- data/lib/jgrouper/group_type/test_case.rb +1 -1
- data/lib/jgrouper/group_type.rb +9 -0
- data/lib/jgrouper/stem/test_case.rb +1 -1
- data/lib/jgrouper/stem.rb +9 -0
- data/lib/jgrouper/subject/test_case.rb +1 -1
- data/lib/jgrouper/subject.rb +9 -0
- data/lib/jgrouper/version.rb +1 -1
- data/lib/jgrouper.rb +32 -13
- data/test/factories.rb +21 -0
- data/test/test_group.rb +60 -0
- metadata +6 -2
data/HISTORY.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
JGrouper History
|
2
2
|
================
|
3
3
|
|
4
|
-
JGrouper v0.0.
|
5
|
-
|
4
|
+
2012-11-20 JGrouper v0.0.5
|
5
|
+
--------------------------
|
6
|
+
* Add *JGrouper::Group#add_type*
|
7
|
+
* Add *JGrouper::Group#delete_type*
|
8
|
+
* Add *JGrouper::Group#method_missing*
|
9
|
+
* Add *JGrouper::Group#types*
|
10
|
+
* Add *JGrouper::GroupType#method_missing*
|
11
|
+
* Add *JGrouper::Stem#method_missing*
|
12
|
+
* Add *JGrouper::Subject#method_missing*
|
13
|
+
* Fix *JGrouper::Group* tests
|
14
|
+
|
15
|
+
2012-10-04 JGrouper v0.0.4
|
16
|
+
--------------------------
|
6
17
|
* Add *JGrouper::Group*
|
7
18
|
* Add *JGrouper::Group.find*
|
8
19
|
* Add *JGrouper::Group* support to *JGrouper::Shell*
|
data/README.rdoc
CHANGED
@@ -5,25 +5,27 @@
|
|
5
5
|
require 'jgrouper'
|
6
6
|
|
7
7
|
# Set path to your Grouper API installation
|
8
|
-
JGrouper.home
|
8
|
+
JGrouper.home '/path/to/your/grouper/api/installation/directory'
|
9
9
|
|
10
10
|
=== Subjects
|
11
11
|
|
12
12
|
# Find root subject
|
13
13
|
JGrouper::Subject.root do |subject|
|
14
|
-
subject.id
|
15
|
-
subject.name
|
16
|
-
subject.source
|
17
|
-
subject.type
|
14
|
+
subject.id # Subject identifier
|
15
|
+
subject.name # Subject name
|
16
|
+
subject.source # Subject source identifier
|
17
|
+
subject.type # Subject type name
|
18
|
+
subject.getSource # Call native Subject API methods
|
18
19
|
end
|
19
20
|
|
20
21
|
=== Stems
|
21
22
|
|
22
23
|
# Find root stem
|
23
24
|
JGrouper::Stem.root do |stem|
|
24
|
-
stem.display_name
|
25
|
-
stem.name
|
26
|
-
stem.uuid
|
25
|
+
stem.display_name # Stem display name
|
26
|
+
stem.name # Stem name
|
27
|
+
stem.uuid # Stem UUID
|
28
|
+
stem.getChildGroups # Call native Grouper API methods
|
27
29
|
end
|
28
30
|
|
29
31
|
# Find by name
|
@@ -39,17 +41,22 @@
|
|
39
41
|
|
40
42
|
# Find by name
|
41
43
|
group = JGrouper::Group.find(name) do |group|
|
42
|
-
group.display_name
|
43
|
-
group.name
|
44
|
-
group.
|
44
|
+
group.display_name # Group display name
|
45
|
+
group.name # Group name
|
46
|
+
group.types # Array of group type names
|
47
|
+
group.uuid # Group UUID
|
48
|
+
group.add_type 'group type' # Add group type
|
49
|
+
group.delete_type 'group_type' # Delete group type
|
50
|
+
group.getParentStem # Call native Grouper API methods
|
45
51
|
end
|
46
52
|
|
47
53
|
=== Group Types
|
48
54
|
|
49
55
|
# Create group type
|
50
56
|
JGrouper::GroupType.create(name) do |group_type|
|
51
|
-
group_type.name
|
52
|
-
group_type.uuid
|
57
|
+
group_type.name # Group type name
|
58
|
+
group_type.uuid # Group type uuid
|
59
|
+
group_type.getFields # Call native Grouper API methods
|
53
60
|
end
|
54
61
|
|
55
62
|
# Find all group types
|
data/Rakefile
CHANGED
data/TODO.md
CHANGED
@@ -1,50 +1,17 @@
|
|
1
1
|
JGrouper To Do
|
2
2
|
==============
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
*
|
7
|
-
*
|
4
|
+
Future
|
5
|
+
------
|
6
|
+
* Fix *JGrouper::Stem* tests
|
7
|
+
* Set (select) *JGrouper::Stem* attributes
|
8
|
+
* List *JGrouper::Stem* privileges
|
9
|
+
* Grant *JGrouper::Stem* privileges
|
10
|
+
* Revoke *JGrouper::Stem* privileges
|
11
|
+
* Set (select) *JGrouper::Group* attributes
|
12
|
+
* Fix *JGrouper::GroupType* tests
|
13
|
+
* Fix *JGrouper::Subject* tests
|
8
14
|
* Add *JGrouper::Stem#children( recurse = false )*
|
9
15
|
* Add *JGrouper::Stem#groups( recurse = false )*
|
10
16
|
* Add *JGrouper::Stem#stems( recurse = false )*
|
11
17
|
|
12
|
-
|
13
|
-
Future
|
14
|
-
------
|
15
|
-
* Add *JGrouper::Stem#add_group( name, display_name = nil )*
|
16
|
-
* Add *JGrouper::Group.create( name, display_name = nil )*
|
17
|
-
* Add *JGrouper::Group#members*
|
18
|
-
* Add *JGrouper::Group#add_member(?)*
|
19
|
-
* Add *JGrouper::Stem#delete( recurse = false )*
|
20
|
-
* Add *JGrouper::Stem.delete( name, recurse = false )*
|
21
|
-
* Add *JGrouper::Stem.find(uuid)*
|
22
|
-
* Add *JGrouper::Stem.exists?(name)*
|
23
|
-
* Add *JGrouper::Group.exists?(name)*
|
24
|
-
* Add *JGrouper::Stem#root?(name)*
|
25
|
-
* Add *JGrouper::Group*
|
26
|
-
* Add *JGrouper::Group.find(name)*
|
27
|
-
* Implement *JGrouper::Subject.sources* (using *edu.internet2.middleware.subject.provider.SourceManager*)
|
28
|
-
* Implement *JGrouper::Subject.source(id)* (using *edu.internet2.middleware.subject.provider.SourceManager*)
|
29
|
-
* Implement *JGrouper::Subject::Source#to_json* (for "jgrouper-server")
|
30
|
-
* Add child stem
|
31
|
-
* Get child stems
|
32
|
-
* Delete child stem
|
33
|
-
* Add child group
|
34
|
-
* Get child groups
|
35
|
-
* Delete child group
|
36
|
-
* Add group member
|
37
|
-
* Get group members
|
38
|
-
* Remove group member
|
39
|
-
* Grant stem privileges
|
40
|
-
* Get stem privileges
|
41
|
-
* Revoke stem privileges
|
42
|
-
* Grant group privileges
|
43
|
-
* Get group privileges
|
44
|
-
* Revoke group privileges
|
45
|
-
* Add privilege to stem and all children
|
46
|
-
* Add privilege to all groups beneath a stem
|
47
|
-
* JGrouper::TestCase
|
48
|
-
* JGrouper::Subject::TestCase
|
49
|
-
* JGrouper::Subject::TestCase
|
50
|
-
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'factory_girl'
|
5
|
+
|
6
|
+
|
7
|
+
class JGrouper::Group::TestCase < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def grouper_wheel_group
|
10
|
+
FactoryGirl.build :grouper_wheel_group
|
11
|
+
end
|
12
|
+
|
13
|
+
def wheel_group_as_json
|
14
|
+
FactoryGirl.attributes_for(:wheel_group).to_json
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
data/lib/jgrouper/group.rb
CHANGED
@@ -4,7 +4,8 @@ module JGrouper # :nodoc:
|
|
4
4
|
#
|
5
5
|
class Group
|
6
6
|
|
7
|
-
|
7
|
+
attr_reader :display_extension, :display_name, :extension, :name, :types, :uuid
|
8
|
+
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
@grouper_group = nil
|
@@ -12,52 +13,31 @@ module JGrouper # :nodoc:
|
|
12
13
|
self
|
13
14
|
end
|
14
15
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# XXX yield child if block_given?
|
41
|
-
# XXX child
|
42
|
-
# XXX end
|
43
|
-
# XXX
|
44
|
-
# XXX #
|
45
|
-
# XXX # Create stem (along with missing intermediaries).
|
46
|
-
# XXX #
|
47
|
-
# XXX # # Create top-level 'foo' stem
|
48
|
-
# XXX # stem = JGrouper::Stem.create 'foo'
|
49
|
-
# XXX #
|
50
|
-
# XXX # # Create top-level 'foo' stem with display name of 'Foo'
|
51
|
-
# XXX # stem = JGrouper::Stem.create 'foo', 'Foo'
|
52
|
-
# XXX #
|
53
|
-
# XXX # # Create 'foo:bar:baz' stem, along with any missing intermediaries
|
54
|
-
# XXX # stem = JGrouper::Stem.create 'foo:bar:baz'
|
55
|
-
# XXX #
|
56
|
-
# XXX def self.create( name, display_name = nil )
|
57
|
-
# XXX stem = root.add_stem name, display_name
|
58
|
-
# XXX yield stem if block_given?
|
59
|
-
# XXX stem
|
60
|
-
# XXX end
|
16
|
+
#
|
17
|
+
# Add group type. Returns +true+ if type added or group already has type.
|
18
|
+
#
|
19
|
+
# group.add_type 'group type'
|
20
|
+
#
|
21
|
+
def add_type(name)
|
22
|
+
return true if types.include? name
|
23
|
+
t = Java::EduInternet2MiddlewareGrouper::GroupTypeFinder.find name, false
|
24
|
+
return false unless t
|
25
|
+
@grouper_group.add_type t
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Delete group type. Returns +true+ if type deleted or group does not have type.
|
31
|
+
#
|
32
|
+
# group.delete_type 'group type'
|
33
|
+
#
|
34
|
+
def delete_type(name)
|
35
|
+
t = Java::EduInternet2MiddlewareGrouper::GroupTypeFinder.find name, false
|
36
|
+
return false unless t
|
37
|
+
return true unless types.include? name
|
38
|
+
@grouper_group.delete_type t
|
39
|
+
true
|
40
|
+
end
|
61
41
|
|
62
42
|
#
|
63
43
|
# Find group by name or returns +nil+.
|
@@ -65,39 +45,55 @@ module JGrouper # :nodoc:
|
|
65
45
|
# group = JGrouper::Group.find(name)
|
66
46
|
#
|
67
47
|
def self.find(name)
|
68
|
-
group = from_grouper GroupFinder.findByName( GrouperSession.startRootSession, name, false ) #
|
48
|
+
group = from_grouper GroupFinder.findByName( GrouperSession.startRootSession, name, false ) # How to handle sessions?
|
69
49
|
yield group if block_given?
|
70
50
|
group
|
71
51
|
end
|
72
52
|
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
53
|
+
#
|
54
|
+
# Generate JGrouper::Group instance from JSON by calling +JSON.parse(json_string)+
|
55
|
+
#
|
56
|
+
def self.json_create(json)
|
57
|
+
new do |group|
|
58
|
+
group.instance_variable_set :@display_extension, json['display_extension']
|
59
|
+
group.instance_variable_set :@display_name, json['display_name']
|
60
|
+
group.instance_variable_set :@extension, json['extension']
|
61
|
+
group.instance_variable_set :@name, json['name']
|
62
|
+
group.instance_variable_set :@types, json['types']
|
63
|
+
group.instance_variable_set :@uuid, json['uuid']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def method_missing(meth, *args, &block)
|
68
|
+
begin
|
69
|
+
warn "METHOD_MISSING: meth=#{ meth } args=#{ args }"
|
70
|
+
block.call @grouper_group.send(meth, *args) if block
|
71
|
+
@grouper_group.send(meth, *args)
|
72
|
+
rescue NoMethodError
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Return JSON representation of JGrouper::Group instance.
|
79
|
+
#
|
80
|
+
def to_json
|
81
|
+
{
|
82
|
+
:json_class => self.class.name,
|
83
|
+
:display_extension => self.display_extension,
|
84
|
+
:display_name => self.display_name,
|
85
|
+
:extension => self.extension,
|
86
|
+
:name => self.name,
|
87
|
+
:types => self.types,
|
88
|
+
:uuid => self.uuid
|
89
|
+
}.to_json
|
90
|
+
end
|
95
91
|
|
96
92
|
#
|
97
93
|
# Return String representation of JGrouper::Group instance.
|
98
94
|
#
|
99
95
|
def to_s
|
100
|
-
%w( name display_name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.join(' | ')
|
96
|
+
%w( name display_name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.join(' | ') + " | types=#{ types.join(',') }"
|
101
97
|
end
|
102
98
|
|
103
99
|
|
@@ -106,11 +102,14 @@ module JGrouper # :nodoc:
|
|
106
102
|
def self.from_grouper(grouper)
|
107
103
|
return nil if grouper.nil?
|
108
104
|
new do |group|
|
109
|
-
group.instance_variable_set :@grouper_group,
|
110
|
-
|
111
|
-
group.display_name
|
112
|
-
group.
|
113
|
-
group.
|
105
|
+
group.instance_variable_set :@grouper_group, grouper
|
106
|
+
group.instance_variable_set :@display_extension, grouper.getDisplayExtension
|
107
|
+
group.instance_variable_set :@display_name, grouper.getDisplayName
|
108
|
+
group.instance_variable_set :@extension, grouper.getExtension
|
109
|
+
group.instance_variable_set :@name, grouper.getName
|
110
|
+
# TODO Testing hack
|
111
|
+
group.instance_variable_set :@types, grouper.getTypes.collect { |t| t.kind_of?(String) ? t : t.getName }
|
112
|
+
group.instance_variable_set :@uuid, grouper.getUuid
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
data/lib/jgrouper/group_type.rb
CHANGED
@@ -84,6 +84,15 @@ module JGrouper # :nodoc:
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
def method_missing(meth, *args, &block)
|
88
|
+
begin
|
89
|
+
block.call @grouper_group_type.send(meth, *args) if block
|
90
|
+
@grouper_group_type.send(meth, *args)
|
91
|
+
rescue NoMethodError
|
92
|
+
super
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
87
96
|
#
|
88
97
|
# Return JSON representation of JGrouper::GroupType instance.
|
89
98
|
#
|
data/lib/jgrouper/stem.rb
CHANGED
@@ -81,6 +81,15 @@ module JGrouper # :nodoc:
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
def method_missing(meth, *args, &block)
|
85
|
+
begin
|
86
|
+
block.call @grouper_stem.send(meth, *args) if block
|
87
|
+
@grouper_stem.send(meth, *args)
|
88
|
+
rescue NoMethodError
|
89
|
+
super
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
84
93
|
#
|
85
94
|
# Return root stem.
|
86
95
|
#
|
data/lib/jgrouper/subject.rb
CHANGED
@@ -24,6 +24,15 @@ module JGrouper #: :nodoc:
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def method_missing(meth, *args, &block)
|
28
|
+
begin
|
29
|
+
block.call @grouper_subject.send(meth, *args) if block
|
30
|
+
@grouper_subject.send(meth, *args)
|
31
|
+
rescue NoMethodError
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
27
36
|
#
|
28
37
|
# Return root subject.
|
29
38
|
#
|
data/lib/jgrouper/version.rb
CHANGED
data/lib/jgrouper.rb
CHANGED
@@ -16,25 +16,27 @@ require_relative 'jgrouper/version'
|
|
16
16
|
# require 'jgrouper'
|
17
17
|
#
|
18
18
|
# # Set path to your Grouper API installation
|
19
|
-
# JGrouper.home
|
19
|
+
# JGrouper.home '/path/to/your/grouper/api/installation/directory'
|
20
20
|
#
|
21
21
|
# === Subjects
|
22
22
|
#
|
23
23
|
# # Find root subject
|
24
24
|
# JGrouper::Subject.root do |subject|
|
25
|
-
# subject.id
|
26
|
-
# subject.name
|
27
|
-
# subject.source
|
28
|
-
# subject.type
|
25
|
+
# subject.id # Subject identifier
|
26
|
+
# subject.name # Subject name
|
27
|
+
# subject.source # Subject source identifier
|
28
|
+
# subject.type # Subject type name
|
29
|
+
# subject.getSource # Call native Subject API methods
|
29
30
|
# end
|
30
31
|
#
|
31
32
|
# === Stems
|
32
33
|
#
|
33
34
|
# # Find root stem
|
34
35
|
# JGrouper::Stem.root do |stem|
|
35
|
-
# stem.display_name
|
36
|
-
# stem.name
|
37
|
-
# stem.uuid
|
36
|
+
# stem.display_name # Stem display name
|
37
|
+
# stem.name # Stem name
|
38
|
+
# stem.uuid # Stem UUID
|
39
|
+
# stem.getChildGroups # Call native Grouper API methods
|
38
40
|
# end
|
39
41
|
#
|
40
42
|
# # Find by name
|
@@ -50,17 +52,22 @@ require_relative 'jgrouper/version'
|
|
50
52
|
#
|
51
53
|
# # Find by name
|
52
54
|
# group = JGrouper::Group.find(name) do |group|
|
53
|
-
# group.display_name
|
54
|
-
# group.name
|
55
|
-
# group.
|
55
|
+
# group.display_name # Group display name
|
56
|
+
# group.name # Group name
|
57
|
+
# group.types # Array of group type names
|
58
|
+
# group.uuid # Group UUID
|
59
|
+
# group.add_type 'group type' # Add group type
|
60
|
+
# group.delete_type 'group_type' # Delete group type
|
61
|
+
# group.getParentStem # Call native Grouper API methods
|
56
62
|
# end
|
57
63
|
#
|
58
64
|
# === Group Types
|
59
65
|
#
|
60
66
|
# # Create group type
|
61
67
|
# JGrouper::GroupType.create(name) do |group_type|
|
62
|
-
# group_type.name
|
63
|
-
# group_type.uuid
|
68
|
+
# group_type.name # Group type name
|
69
|
+
# group_type.uuid # Group type uuid
|
70
|
+
# group_type.getFields # Call native Grouper API methods
|
64
71
|
# end
|
65
72
|
#
|
66
73
|
# # Find all group types
|
@@ -133,5 +140,17 @@ module JGrouper
|
|
133
140
|
).each { |klass| include_class klass }
|
134
141
|
end
|
135
142
|
|
143
|
+
#
|
144
|
+
# Initialize Grouper API.
|
145
|
+
#
|
146
|
+
def self.home=(path)
|
147
|
+
self.home path
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
if __FILE__ == $0
|
153
|
+
JGrouper.home ENV['GROUPER_HOME']
|
154
|
+
puts JGrouper::Group.find('etc:wheel')
|
136
155
|
end
|
137
156
|
|
data/test/factories.rb
CHANGED
@@ -4,6 +4,27 @@ require 'factory_girl'
|
|
4
4
|
|
5
5
|
|
6
6
|
FactoryGirl.define do
|
7
|
+
# Groups
|
8
|
+
factory :grouper_wheel_group, class: OpenStruct do
|
9
|
+
getDisplayExtension 'Wheel'
|
10
|
+
getDisplayName 'Etc:Wheel'
|
11
|
+
getExtension 'wheel'
|
12
|
+
getName 'etc:wheel'
|
13
|
+
getTypes [ 'base'] # FIXME
|
14
|
+
getUuid 'etc-wheel-group'
|
15
|
+
end
|
16
|
+
|
17
|
+
factory :wheel_group, class: OpenStruct do
|
18
|
+
json_class JGrouper::Group
|
19
|
+
display_extension 'Wheel'
|
20
|
+
display_name 'Etc:Wheel'
|
21
|
+
extension 'wheel'
|
22
|
+
name 'etc:wheel'
|
23
|
+
types [ 'base' ]
|
24
|
+
uuid 'etc-wheel-group'
|
25
|
+
end
|
26
|
+
|
27
|
+
|
7
28
|
# Group Types
|
8
29
|
factory :jgrouper_type, class: OpenStruct do
|
9
30
|
json_class JGrouper::GroupType
|
data/test/test_group.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
require_relative '../lib/jgrouper/group/test_case'
|
5
|
+
|
6
|
+
|
7
|
+
class JGrouper::Group::TestCase < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_mocked_find_wheel
|
10
|
+
Java::EduInternet2MiddlewareGrouper::GrouperSession.expects(:startRootSession).returns true
|
11
|
+
Java::EduInternet2MiddlewareGrouper::GroupFinder.expects(:findByName).returns grouper_wheel_group
|
12
|
+
|
13
|
+
JGrouper::Group.find('etc:wheel') do |group|
|
14
|
+
assert_not_nil group
|
15
|
+
assert group.kind_of? JGrouper::Group
|
16
|
+
assert_equal 'Wheel', group.display_extension
|
17
|
+
assert_equal 'Etc:Wheel', group.display_name
|
18
|
+
assert_equal 'wheel', group.extension
|
19
|
+
assert_equal 'etc:wheel', group.name
|
20
|
+
assert_equal [ 'base' ], group.types # FIXME
|
21
|
+
assert_equal 'etc-wheel-group', group.uuid
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_mocked_group_to_json
|
26
|
+
Java::EduInternet2MiddlewareGrouper::GrouperSession.expects(:startRootSession).returns true
|
27
|
+
Java::EduInternet2MiddlewareGrouper::GroupFinder.expects(:findByName).returns grouper_wheel_group
|
28
|
+
|
29
|
+
assert_equal wheel_group_as_json, JGrouper::Group.find('etc:wheel').to_json
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_group_from_json
|
33
|
+
group = JSON.parse wheel_group_as_json
|
34
|
+
assert_not_nil group
|
35
|
+
assert group.kind_of? JGrouper::Group
|
36
|
+
assert_equal 'Wheel', group.display_extension
|
37
|
+
assert_equal 'Etc:Wheel', group.display_name
|
38
|
+
assert_equal 'wheel', group.extension
|
39
|
+
assert_equal 'etc:wheel', group.name
|
40
|
+
assert_equal [ 'base' ], group.types
|
41
|
+
assert_equal 'etc-wheel-group', group.uuid
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_group_types
|
45
|
+
Java::EduInternet2MiddlewareGrouper::GrouperSession.expects(:startRootSession).returns true
|
46
|
+
Java::EduInternet2MiddlewareGrouper::GroupFinder.expects(:findByName).returns grouper_wheel_group
|
47
|
+
|
48
|
+
JGrouper::Group.find('etc:wheel') do |group|
|
49
|
+
assert_equal true, group.add_type('base') # Add already present type
|
50
|
+
# TODO Add type
|
51
|
+
assert_equal false, group.add_type('foo') # Add invalid group type
|
52
|
+
|
53
|
+
# TODO Delete unassigned type
|
54
|
+
# TODO Delete type
|
55
|
+
assert_equal false, group.delete_type('foo') # Delete invalid group type
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jgrouper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- jgrouper.gemspec
|
141
141
|
- lib/jgrouper.rb
|
142
142
|
- lib/jgrouper/group.rb
|
143
|
+
- lib/jgrouper/group/test_case.rb
|
143
144
|
- lib/jgrouper/group_type.rb
|
144
145
|
- lib/jgrouper/group_type/test_case.rb
|
145
146
|
- lib/jgrouper/stem.rb
|
@@ -149,6 +150,7 @@ files:
|
|
149
150
|
- lib/jgrouper/version.rb
|
150
151
|
- test/factories.rb
|
151
152
|
- test/helper.rb
|
153
|
+
- test/test_group.rb
|
152
154
|
- test/test_group_type.rb
|
153
155
|
- test/test_stem.rb
|
154
156
|
- test/test_subject.rb
|
@@ -179,6 +181,8 @@ summary: JRuby wrapper around the Internet2 Grouper API
|
|
179
181
|
test_files:
|
180
182
|
- test/factories.rb
|
181
183
|
- test/helper.rb
|
184
|
+
- test/test_group.rb
|
182
185
|
- test/test_group_type.rb
|
183
186
|
- test/test_stem.rb
|
184
187
|
- test/test_subject.rb
|
188
|
+
has_rdoc:
|