google_apps 0.5 → 0.9
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/.gitignore +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +7 -0
- data/README.md +461 -0
- data/google_apps.gemspec +20 -0
- data/lib/google_apps/atom/atom.rb +6 -9
- data/lib/google_apps/atom/export.rb +5 -6
- data/lib/google_apps/atom/feed.rb +17 -6
- data/lib/google_apps/document_handler.rb +6 -38
- data/lib/google_apps/transport.rb +110 -194
- data/spec/credentials.example.yaml +2 -0
- data/spec/fixture_xml/mes_attr.xml +8 -0
- data/spec/fixture_xml/test_doc.xml +5 -0
- data/spec/fixture_xml/user.xml +5 -0
- data/spec/fixture_xml/users_feed.xml +49 -0
- data/spec/google_apps/apps_request_spec.rb +81 -0
- data/spec/google_apps/atom/document_spec.rb +74 -0
- data/spec/google_apps/atom/export_spec.rb +70 -0
- data/spec/google_apps/atom/feed_spec.rb +93 -0
- data/spec/google_apps/atom/group_member_spec.rb +49 -0
- data/spec/google_apps/atom/group_owner_spec.rb +43 -0
- data/spec/google_apps/atom/group_spec.rb +155 -0
- data/spec/google_apps/atom/message_attributes_spec.rb +73 -0
- data/spec/google_apps/atom/nickname_spec.rb +66 -0
- data/spec/google_apps/atom/node_spec.rb +57 -0
- data/spec/google_apps/atom/public_key_spec.rb +32 -0
- data/spec/google_apps/atom/user_spec.rb +304 -0
- data/spec/google_apps/document_handler_spec.rb +48 -0
- data/spec/google_apps/transport_spec.rb +235 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/helpers.rb +66 -0
- metadata +104 -6
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::GroupOwner" do
|
4
|
+
let (:owner) { GoogleApps::Atom::GroupOwner.new }
|
5
|
+
|
6
|
+
describe "#add_address" do
|
7
|
+
it "adds the email property to the document" do
|
8
|
+
owner.add_address 'lholcomb2@cnm.edu'
|
9
|
+
|
10
|
+
owner.to_s.should include 'name="email"'
|
11
|
+
owner.to_s.should include 'value="lholcomb2@cnm.edu"'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#address=" do
|
16
|
+
it "Sets @address if not set" do
|
17
|
+
owner.address = 'tim@bob.com'
|
18
|
+
|
19
|
+
owner.address.should == 'tim@bob.com'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Adds the property node if not present" do
|
23
|
+
owner.address = 'tim@bob.com'
|
24
|
+
|
25
|
+
owner.to_s.should include 'value="tim@bob.com"'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Updates @address if already set" do
|
29
|
+
owner.address = 'tim@bob.com'
|
30
|
+
owner.address = 'steve@dave.com'
|
31
|
+
|
32
|
+
owner.address.should == 'steve@dave.com'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Updates the property node if already present" do
|
36
|
+
owner.address = 'tim@bob.com'
|
37
|
+
owner.address = 'steve@dave.com'
|
38
|
+
|
39
|
+
owner.to_s.should include 'value="steve@dave.com'
|
40
|
+
owner.to_s.should_not include 'value="tim@bob.com"'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::Group" do
|
4
|
+
let (:group) { GoogleApps::Atom::Group.new }
|
5
|
+
|
6
|
+
describe "#new" do
|
7
|
+
it "should initialize @document" do
|
8
|
+
group.instance_eval { @doc }.should be_a LibXML::XML::Document
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should add the header to @document" do
|
12
|
+
group.instance_eval { @doc.root }.should be_an LibXML::XML::Node
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#new_group" do
|
17
|
+
it "should add the properties for the specified group to @document" do
|
18
|
+
group.new_group id: 'ruby', name: 'Ruby', description: 'Ruby Library Test Group', perms: 'Domain'
|
19
|
+
|
20
|
+
document = group.to_s
|
21
|
+
|
22
|
+
document.should include 'ruby'
|
23
|
+
document.should include 'Ruby'
|
24
|
+
document.should include 'Library'
|
25
|
+
document.should include 'Domain'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#set_values" do
|
30
|
+
it "should set the specified values in the XML document" do
|
31
|
+
group.set_values id: 'sample', name: 'Test', description: 'Test Group', perms: 'Domain'
|
32
|
+
document = group.to_s
|
33
|
+
|
34
|
+
document.should include 'sample'
|
35
|
+
document.should include 'Test'
|
36
|
+
document.should include 'Test Group'
|
37
|
+
document.should include 'Domain'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should only set the id if nothing else is specified" do
|
41
|
+
group.set_values id: 'sample'
|
42
|
+
document = group.to_s
|
43
|
+
|
44
|
+
document.should include 'sample'
|
45
|
+
document.should include 'groupId'
|
46
|
+
document.should_not include 'groupName'
|
47
|
+
document.should_not include 'description'
|
48
|
+
document.should_not include 'emailPermissions'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should only set the name if nothing else is specified" do
|
52
|
+
group.set_values name: 'Name'
|
53
|
+
document = group.to_s
|
54
|
+
|
55
|
+
document.should include 'Name'
|
56
|
+
document.should include 'groupName'
|
57
|
+
document.should_not include 'groupId'
|
58
|
+
document.should_not include 'description'
|
59
|
+
document.should_not include 'emailPermissions'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should only set the description if nothing else is specified" do
|
63
|
+
group.set_values description: 'Test Group'
|
64
|
+
document = group.to_s
|
65
|
+
|
66
|
+
document.should include 'description'
|
67
|
+
document.should include 'Test Group'
|
68
|
+
document.should_not include 'groupId'
|
69
|
+
document.should_not include 'groupName'
|
70
|
+
document.should_not include 'emailPermissions'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#id=" do
|
75
|
+
before(:all) do
|
76
|
+
group.id = 'ID'
|
77
|
+
end
|
78
|
+
|
79
|
+
it "Sets the @id value if not already set" do
|
80
|
+
group.id.should == 'ID'
|
81
|
+
group.to_s.should include 'ID'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "Changes the @id value if it is already set" do
|
85
|
+
group.id = 'New ID'
|
86
|
+
|
87
|
+
group.id.should == 'New ID'
|
88
|
+
group.to_s.should include 'New ID'
|
89
|
+
group.to_s.should_not include 'value="ID"'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#name=" do
|
94
|
+
before(:all) do
|
95
|
+
group.name = 'Group'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "Sets @name if not already set" do
|
99
|
+
group.name.should == 'Group'
|
100
|
+
group.to_s.should include 'Group'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "Changes the value of @name if already set" do
|
104
|
+
group.name = 'Fancy Group'
|
105
|
+
|
106
|
+
group.name.should == 'Fancy Group'
|
107
|
+
group.to_s.should include 'Fancy Group'
|
108
|
+
group.to_s.should_not include 'value="Group"'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#description=" do
|
113
|
+
before(:all) do
|
114
|
+
group.description = 'Description'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "Sets @description if not already set" do
|
118
|
+
group.description.should == 'Description'
|
119
|
+
group.to_s.should include 'Description'
|
120
|
+
end
|
121
|
+
|
122
|
+
it "Changes @description if already set" do
|
123
|
+
group.description = 'Elaborate Description'
|
124
|
+
|
125
|
+
group.description.should == 'Elaborate Description'
|
126
|
+
group.to_s.should include 'Elaborate Description'
|
127
|
+
group.to_s.should_not include 'value="Description"'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#permissions=" do
|
132
|
+
before(:all) do
|
133
|
+
group.permissions = 'Allow'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "Sets @permissions if not already set" do
|
137
|
+
group.permissions.should == 'Allow'
|
138
|
+
group.to_s.should include 'Allow'
|
139
|
+
end
|
140
|
+
|
141
|
+
it "Changes @permissions if already set" do
|
142
|
+
group.permissions = 'Deny'
|
143
|
+
|
144
|
+
group.permissions.should == 'Deny'
|
145
|
+
group.to_s.should include 'Deny'
|
146
|
+
group.to_s.should_not include 'Allow'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#to_s" do
|
151
|
+
it "should present @document as a string" do
|
152
|
+
group.to_s.should be_a String
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::MessageAttributes" do
|
4
|
+
let (:attributes) { GoogleApps::Atom::MessageAttributes.new }
|
5
|
+
|
6
|
+
describe "#new" do
|
7
|
+
it "should initialize @doc to a LibXML::XML::Document" do
|
8
|
+
attributes.instance_eval { @doc }.should be_a LibXML::XML::Document
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should set the @document header" do
|
12
|
+
attributes.to_s.should include 'term'
|
13
|
+
attributes.to_s.should include 'scheme'
|
14
|
+
attributes.to_s.should include 'type'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_s" do
|
19
|
+
it "should return @document as a String" do
|
20
|
+
attributes.to_s.should be_a String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#add_property" do
|
25
|
+
it "should add a property attribute to @document" do
|
26
|
+
attributes.add_property 'IS_INBOX'
|
27
|
+
|
28
|
+
attributes.to_s.should include 'mailItemProperty'
|
29
|
+
attributes.to_s.should include 'IS_INBOX'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#add_label" do
|
34
|
+
it "should add a label attribute to @document" do
|
35
|
+
attributes.add_label 'Migration'
|
36
|
+
|
37
|
+
attributes.to_s.should include 'label'
|
38
|
+
attributes.to_s.should include 'Migration'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#remove_label" do
|
43
|
+
before(:each) do
|
44
|
+
attributes.add_label 'Migration'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "Removes a label from the object" do
|
48
|
+
attributes.remove_label 'Migration'
|
49
|
+
|
50
|
+
attributes.labels.should == []
|
51
|
+
end
|
52
|
+
|
53
|
+
it "Removes a label from the document" do
|
54
|
+
attributes.remove_label 'Migration'
|
55
|
+
|
56
|
+
attributes.to_s.should_not include 'labelName="Migration"'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#find_labels" do
|
61
|
+
before(:all) do
|
62
|
+
@fetched = GoogleApps::Atom::MessageAttributes.new File.read('spec/fixture_xml/mes_attr.xml')
|
63
|
+
end
|
64
|
+
|
65
|
+
it "Populates @labels according to the provided xml" do
|
66
|
+
@fetched.labels.should == ['test', 'label']
|
67
|
+
end
|
68
|
+
|
69
|
+
it "Populates the property value based on the provided xml" do
|
70
|
+
@fetched.property.should == 'Inbox'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::Nickname" do
|
4
|
+
let (:nick) { GoogleApps::Atom::Nickname.new }
|
5
|
+
|
6
|
+
describe "#new" do
|
7
|
+
it "Initializes the document header" do
|
8
|
+
nick.doc.to_s.should include '<?xml version="1.0" encoding="UTF-8"?>'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Initializes an XML document" do
|
12
|
+
nick.doc.should be_a LibXML::XML::Document
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#to_s" do
|
17
|
+
it "Returns @document as a string" do
|
18
|
+
nick.to_s.should be_a String
|
19
|
+
nick.to_s.should == nick.doc.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#nickname=" do
|
24
|
+
it "Sets the nickname attribute on the document" do
|
25
|
+
nick.nickname = 'Bob'
|
26
|
+
|
27
|
+
nick.to_s.should include 'apps:nickname name="Bob"'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Sets the nickname value in the object" do
|
31
|
+
nick.nickname = 'Tom'
|
32
|
+
|
33
|
+
nick.nickname.should == 'Tom'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "Changes the value of the nickname attribute if nickname is already set" do
|
37
|
+
nick.nickname = 'Lou'
|
38
|
+
nick.nickname = 'Al'
|
39
|
+
|
40
|
+
nick.to_s.should include 'apps:nickname name="Al"'
|
41
|
+
nick.to_s.should_not include 'apps:nickname name="Lou"'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#user=" do
|
46
|
+
it "Sets the username attribute on the document" do
|
47
|
+
nick.user = 'tim@joe.com'
|
48
|
+
|
49
|
+
nick.to_s.should include 'apps:login userName="tim@joe.com"'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Sets the username value in the object" do
|
53
|
+
nick.user = 'jimmy@jim.com'
|
54
|
+
|
55
|
+
nick.user.should == 'jimmy@jim.com'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "Changes the value of the apps:login element if user is already set" do
|
59
|
+
nick.user = 'lou@bob'
|
60
|
+
nick.user = 'tom@bob'
|
61
|
+
|
62
|
+
nick.to_s.should include 'apps:login userName="tom@bob"'
|
63
|
+
nick.to_s.should_not include 'apps:login userName="lou@bob"'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::Node" do
|
4
|
+
let (:node_class) { class TestNode < BasicObject; include ::GoogleApps::Atom::Node; end }
|
5
|
+
let (:node) { node_class.new }
|
6
|
+
let (:document) { LibXML::XML::Document.file('spec/fixture_xml/test_doc.xml') }
|
7
|
+
|
8
|
+
describe "#create_node" do
|
9
|
+
it "Creates a LibXML::XML::Node with the given attributes" do
|
10
|
+
sample = node.create_node type: 'apps:nickname', attrs: [['name', 'Bob']]
|
11
|
+
|
12
|
+
sample.to_s.should include 'apps:nickname name="Bob"'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "Creates a Node with multiple attributes" do
|
16
|
+
sample = node.create_node type: 'apps:nickname', attrs: [['name', 'Lou'], ['type', 'fake']]
|
17
|
+
|
18
|
+
sample.to_s.should include 'apps:nickname name="Lou" type="fake"'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "Creates a LibXML::XML::Node without attributes if none are given" do
|
22
|
+
(node.create_node type: 'apps:nickname').to_s.should include 'apps:nickname'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#add_prop_node" do
|
27
|
+
it "Adds an apps:property node to the document root" do
|
28
|
+
node.add_prop_node 'email', 'tom', document.root
|
29
|
+
|
30
|
+
document.to_s.should include 'value="tom"'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#add_attributes" do
|
35
|
+
it "Adds the specified attributes to the given node" do
|
36
|
+
test = LibXML::XML::Node.new 'apps:test'
|
37
|
+
node.add_attributes(test, [['name', 'frank'], ['title', 'captain']])
|
38
|
+
|
39
|
+
test.to_s.should include 'name="frank" title="captain"'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#get_content" do
|
44
|
+
it "Returns the content of the specified node" do
|
45
|
+
node.get_content(document, '//title').should == 'Users'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#add_namespaces" do
|
50
|
+
it "Adds the specified namespaces to the given node" do
|
51
|
+
test = node.create_node type: 'atom:entry'
|
52
|
+
node.add_namespaces(test, atom: 'http://www.w3.org/2005/Atom')
|
53
|
+
|
54
|
+
test.to_s.should include 'xmlns:atom="http://www.w3.org/2005/Atom"'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::PublicKey" do
|
4
|
+
let (:pub_key) { GoogleApps::Atom::PublicKey.new }
|
5
|
+
let (:key) { 'not really a key' }
|
6
|
+
|
7
|
+
describe "#new" do
|
8
|
+
it "Initializes @doc to be a LibXML::XML::Document" do
|
9
|
+
pub_key.doc.should be_a LibXML::XML::Document
|
10
|
+
end
|
11
|
+
|
12
|
+
it "Adds the root node to @document" do
|
13
|
+
pub_key.to_s.should include '<atom:entry'
|
14
|
+
pub_key.to_s.should include 'xmlns:atom'
|
15
|
+
pub_key.to_s.should include 'xmlns:apps'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#new_key" do
|
20
|
+
it "should add the publicKey property to @document" do
|
21
|
+
pub_key.new_key key
|
22
|
+
|
23
|
+
pub_key.to_s.should include 'name="publicKey"'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#to_s" do
|
28
|
+
it "should return @document as a String" do
|
29
|
+
pub_key.to_s.should be_a String
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,304 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GoogleApps::Atom::User" do
|
4
|
+
let (:gapp) { GoogleApps::Atom::User.new }
|
5
|
+
let (:user) { ["test_account", "Test", "Account", "db64e604690686663821888f20373a3941ed7e95", 2048] }
|
6
|
+
let (:xml) { File.read('spec/fixture_xml/user.xml') }
|
7
|
+
let (:default_password) { 'default' }
|
8
|
+
|
9
|
+
describe '#new' do
|
10
|
+
it "creates an empty XML document when given no arguments" do
|
11
|
+
gapp.doc.should be_a LibXML::XML::Document
|
12
|
+
end
|
13
|
+
|
14
|
+
it "adds the root element to @doc" do
|
15
|
+
gapp.doc.to_s.should include '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "adds the category element to @doc" do
|
19
|
+
gapp.doc.to_s.should include '<apps:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/apps/2006#user"/>'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "creates an xml document matching the given argument" do
|
23
|
+
usr = GoogleApps::Atom.user xml
|
24
|
+
|
25
|
+
usr.doc.to_s.should include xml
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#set" do
|
30
|
+
it "Adds the login attribute to the document" do
|
31
|
+
gapp.set login: 'Zudder'
|
32
|
+
|
33
|
+
gapp.to_s.should include 'userName="Zudder"'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "Adds the password attributes to the document" do
|
37
|
+
gapp.set password: 'taco salad'
|
38
|
+
|
39
|
+
gapp.to_s.should include "password=\"#{hash_password('taco salad')}\""
|
40
|
+
gapp.to_s.should include 'hashFunctionName="SHA'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "Adds the quota attribute to the document" do
|
44
|
+
gapp.set quota: 12344
|
45
|
+
|
46
|
+
gapp.to_s.should include 'limit="12344"'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "Adds the suspended attribute to the document" do
|
50
|
+
gapp.set suspended: true
|
51
|
+
|
52
|
+
gapp.to_s.should include 'suspended="true"'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "Adds the first name to the document" do
|
56
|
+
gapp.set first_name: 'Luke'
|
57
|
+
|
58
|
+
gapp.to_s.should include 'givenName="Luke"'
|
59
|
+
end
|
60
|
+
|
61
|
+
it "Adds the last name to the document" do
|
62
|
+
gapp.set last_name: 'Olsen'
|
63
|
+
|
64
|
+
gapp.to_s.should include 'familyName="Olsen"'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#add_node" do
|
69
|
+
it "Creates the specified node and parses the document" do
|
70
|
+
gapp.add_node 'apps:login', [['suspended', 'false']]
|
71
|
+
|
72
|
+
gapp.to_s.should include '<apps:login suspended="false"/>'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#update_node" do
|
77
|
+
it "Updated an existing node with the given values" do
|
78
|
+
gapp.add_node 'apps:login', [['userName', 'Zud']]
|
79
|
+
gapp.instance_eval { @login = 'Zud' }
|
80
|
+
gapp.update_node 'apps:login', :userName, 'Bran'
|
81
|
+
|
82
|
+
gapp.to_s.should include 'userName="Bran"'
|
83
|
+
gapp.to_s.should_not include 'userName="Zud"'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#node" do
|
88
|
+
it "Checks the document for a node with the given name" do
|
89
|
+
gapp.suspended = true
|
90
|
+
|
91
|
+
gapp.node('apps:login').should_not be nil
|
92
|
+
gapp.node('bacon').should be nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#suspended=" do
|
97
|
+
it "Sets the suspended attribute on the apps:login node" do
|
98
|
+
gapp.suspended = true
|
99
|
+
|
100
|
+
gapp.to_s.should include 'suspended="true"'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "Sets @suspended to the given value" do
|
104
|
+
gapp.suspended = true
|
105
|
+
|
106
|
+
gapp.suspended.should == true
|
107
|
+
end
|
108
|
+
|
109
|
+
it "Changes the value of suspended in apps:login if already set" do
|
110
|
+
gapp.suspended = true
|
111
|
+
gapp.suspended = false
|
112
|
+
|
113
|
+
gapp.to_s.should include 'suspended="false"'
|
114
|
+
gapp.to_s.should_not include 'suspended="true"'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "Sets @suspended to the given value if previously set" do
|
118
|
+
gapp.suspended = true
|
119
|
+
gapp.suspended = false
|
120
|
+
|
121
|
+
gapp.suspended.should == false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#login=" do
|
126
|
+
it "Sets the userName attribute on the apps:login node" do
|
127
|
+
gapp.login = 'bob'
|
128
|
+
|
129
|
+
gapp.to_s.should include 'userName="bob"'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "Sets @login to the given value" do
|
133
|
+
gapp.login = 'bob'
|
134
|
+
|
135
|
+
gapp.login.should == 'bob'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "Changes the value of userName in apps:login if already set" do
|
139
|
+
gapp.login = 'bob'
|
140
|
+
gapp.login = 'lou'
|
141
|
+
|
142
|
+
gapp.to_s.should include 'userName="lou"'
|
143
|
+
gapp.to_s.should_not include 'userName="bob"'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "Sets @login to the given value if previously set" do
|
147
|
+
gapp.login = 'bob'
|
148
|
+
gapp.login = 'lou'
|
149
|
+
|
150
|
+
gapp.login.should == 'lou'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#first_name=" do
|
155
|
+
it "Sets the givenName attribute on the apps:name node" do
|
156
|
+
gapp.first_name = 'Sam'
|
157
|
+
|
158
|
+
gapp.to_s.should include 'givenName="Sam"'
|
159
|
+
end
|
160
|
+
|
161
|
+
it "Sets @first_name to the given value" do
|
162
|
+
gapp.first_name = 'Sam'
|
163
|
+
|
164
|
+
gapp.first_name.should == 'Sam'
|
165
|
+
end
|
166
|
+
|
167
|
+
it "Changes the value of givenName in apps:name if already set" do
|
168
|
+
gapp.first_name = 'Sam'
|
169
|
+
gapp.first_name = 'June'
|
170
|
+
|
171
|
+
gapp.to_s.should include 'givenName="June"'
|
172
|
+
gapp.to_s.should_not include 'givenName="Sam"'
|
173
|
+
end
|
174
|
+
|
175
|
+
it "Sets @first_name to the given value if previously set" do
|
176
|
+
gapp.first_name = 'Sam'
|
177
|
+
gapp.first_name = 'June'
|
178
|
+
|
179
|
+
gapp.first_name.should == 'June'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "#last_name=" do
|
184
|
+
it "Sets the familyName attribute on the apps:name node" do
|
185
|
+
gapp.last_name = 'Strange'
|
186
|
+
|
187
|
+
gapp.to_s.should include 'familyName="Strange"'
|
188
|
+
end
|
189
|
+
|
190
|
+
it "Sets @last_name to the given value" do
|
191
|
+
gapp.last_name = 'Strange'
|
192
|
+
|
193
|
+
gapp.last_name.should == 'Strange'
|
194
|
+
end
|
195
|
+
|
196
|
+
it "Changes the value of familyName in apps:name if already set" do
|
197
|
+
gapp.last_name = 'Strange'
|
198
|
+
gapp.last_name = 'Parker'
|
199
|
+
|
200
|
+
gapp.to_s.should include 'familyName="Parker"'
|
201
|
+
gapp.to_s.should_not include 'familyName="Strange"'
|
202
|
+
end
|
203
|
+
|
204
|
+
it "Sets @last_name to the given value if previously set" do
|
205
|
+
gapp.last_name = 'Strange'
|
206
|
+
gapp.last_name = 'Parker'
|
207
|
+
|
208
|
+
gapp.last_name.should == 'Parker'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#quota=" do
|
213
|
+
it "Sets the limit attribute on the apps:quota node" do
|
214
|
+
gapp.quota = 12354
|
215
|
+
|
216
|
+
gapp.to_s.should include 'limit="12354"'
|
217
|
+
end
|
218
|
+
|
219
|
+
it "Sets @quota to the given value" do
|
220
|
+
gapp.quota = 12354
|
221
|
+
|
222
|
+
gapp.quota.should == 12354
|
223
|
+
end
|
224
|
+
|
225
|
+
it "Changes the value of limit in apps:quota if already set" do
|
226
|
+
gapp.quota = 12354
|
227
|
+
gapp.quota = 123456
|
228
|
+
|
229
|
+
gapp.to_s.should include 'limit="123456"'
|
230
|
+
gapp.to_s.should_not include 'limit="12354"'
|
231
|
+
end
|
232
|
+
|
233
|
+
it "Sets @quota to the given value if previously set" do
|
234
|
+
gapp.quota = 12354
|
235
|
+
gapp.quota = 123456
|
236
|
+
|
237
|
+
gapp.quota.should == 123456
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "#password=" do
|
242
|
+
before(:all) do
|
243
|
+
@hashed = hash_password(default_password)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "Sets the password attribute on the apps:login node" do
|
247
|
+
gapp.password = default_password
|
248
|
+
|
249
|
+
gapp.to_s.should include "password=\"#{@hashed}\""
|
250
|
+
end
|
251
|
+
|
252
|
+
it "Sets the hashFunctionName attribute on the apps:login node" do
|
253
|
+
gapp.password = default_password
|
254
|
+
|
255
|
+
gapp.to_s.should include "hashFunctionName=\"#{GoogleApps::Atom::HASH_FUNCTION}\""
|
256
|
+
end
|
257
|
+
|
258
|
+
it "Sets @password to the given value" do
|
259
|
+
gapp.password = default_password
|
260
|
+
|
261
|
+
gapp.password.should == @hashed
|
262
|
+
end
|
263
|
+
|
264
|
+
it "Updates the password attribute in apps:login if already set" do
|
265
|
+
gapp.password = default_password
|
266
|
+
gapp.password = 'new password'
|
267
|
+
|
268
|
+
gapp.to_s.should include "password=\"#{hash_password('new password')}\""
|
269
|
+
gapp.to_s.should_not include "password=\"#{@hashed}\""
|
270
|
+
end
|
271
|
+
|
272
|
+
it "Updates @password if previously set" do
|
273
|
+
gapp.password = default_password
|
274
|
+
gapp.password = 'new password'
|
275
|
+
|
276
|
+
gapp.password.should == hash_password('new password')
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe "#find_values" do
|
281
|
+
it "Populates instance variables with values from @doc" do
|
282
|
+
user = GoogleApps::Atom::User.new xml
|
283
|
+
|
284
|
+
user.login.should == 'lholcomb2'
|
285
|
+
user.suspended.should == false
|
286
|
+
user.first_name.should == 'Lawrence'
|
287
|
+
user.last_name.should == 'Holcomb'
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
describe "#check_value" do
|
292
|
+
it "Returns true if the value is 'true'" do
|
293
|
+
gapp.send(:check_value, 'true').should == true
|
294
|
+
end
|
295
|
+
|
296
|
+
it "Returns flase if the value is 'false'" do
|
297
|
+
gapp.send(:check_value, 'false').should == false
|
298
|
+
end
|
299
|
+
|
300
|
+
it "Returns the origional object if not == 'true' or 'false'" do
|
301
|
+
gapp.send(:check_value, 'bob').should == 'bob'
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|