gprov 0.0.5 → 0.0.7
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/README.markdown +10 -4
- data/lib/gprov/connection.rb +12 -5
- data/lib/gprov/version.rb +1 -1
- data/spec/gprov/auth/clientlogin_spec.rb +29 -28
- data/spec/gprov/connection_spec.rb +19 -20
- data/spec/gprov/provision/entrybase/classmethods_spec.rb +12 -0
- data/spec/gprov/provision/entrybase_spec.rb +3 -31
- data/spec/gprov/provision/group.rb +9 -0
- data/spec/gprov/provision/orgunit.rb +9 -0
- data/spec/gprov/provision/user.rb +8 -0
- data/spec/lib/fakeentry.rb +6 -0
- data/spec/spec_helper.rb +1 -0
- metadata +9 -4
data/README.markdown
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
Ruby-GProv
|
2
2
|
==========
|
3
3
|
|
4
|
+
Synopsis
|
5
|
+
--------
|
6
|
+
|
7
|
+
This is a ruby implementation of the Ruby implementation of the [Google Provisioning API][api].
|
8
|
+
|
4
9
|
Description
|
5
10
|
-----------
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
The specification of the Google Provisioning API is primarily procedural in
|
13
|
+
nature, despite that all the languages that Google provides bindings for are
|
14
|
+
object oriented. This implementation attempts to provide a more natural
|
15
|
+
interface to that API. Where applicable, objects present a CRUD-like set of
|
16
|
+
methods to perform operations on the underlying system.
|
11
17
|
|
12
18
|
[api]: http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_reference.html "Google Provisioning API v2.0"
|
13
19
|
|
data/lib/gprov/connection.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# =
|
1
|
+
# = GProv::Connection: common interface for the google apps API
|
2
2
|
#
|
3
3
|
# == Overview
|
4
4
|
#
|
@@ -52,8 +52,15 @@ module GProv
|
|
52
52
|
if path.nil?
|
53
53
|
raise "#{self.class}##{verb} requires a non-nil path"
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
# If extra headers were passed in, explode the containing array. Else,
|
57
|
+
# create a new empty hash. When that's done, merge the Google API
|
58
|
+
# headers.
|
59
|
+
case args.length
|
60
|
+
when 0 then options = {}
|
61
|
+
when 1 then options = args.pop
|
62
|
+
else options = *args
|
63
|
+
end
|
57
64
|
options.merge! default_headers
|
58
65
|
|
59
66
|
# Interpolate the :domain substring into a url to allow for the domain
|
@@ -61,8 +68,8 @@ module GProv
|
|
61
68
|
path.gsub!(":domain", @domain)
|
62
69
|
|
63
70
|
if options[:noop] or @options[:noop]
|
64
|
-
|
65
|
-
|
71
|
+
warn "Would have attempted the following call"
|
72
|
+
warn "#{verb} #{path} #{options.inspect}"
|
66
73
|
else
|
67
74
|
# Return the request to the calling class so that the caller can
|
68
75
|
# determine the outcome of the request.
|
data/lib/gprov/version.rb
CHANGED
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe GProv::Auth::ClientLogin do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
let(:klass) { GProv::Auth::ClientLogin }
|
6
|
+
|
7
|
+
let(:dummy_form) do
|
8
|
+
{:body => {
|
9
9
|
"accountType" => "HOSTED",
|
10
10
|
"Email" => "test",
|
11
11
|
"Passwd" => "password",
|
@@ -13,35 +13,36 @@ describe GProv::Auth::ClientLogin do
|
|
13
13
|
}}
|
14
14
|
end
|
15
15
|
|
16
|
+
subject { GProv::Auth::ClientLogin.new('test', 'password', 'service') }
|
17
|
+
|
16
18
|
it "should use the google ClientLogin uri" do
|
17
|
-
|
19
|
+
klass.base_uri.should == "https://www.google.com/accounts/ClientLogin"
|
18
20
|
end
|
19
21
|
|
20
|
-
it
|
21
|
-
@instance.respond_to?(:token).should == true
|
22
|
-
end
|
22
|
+
it { should respond_to :token }
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
stub_response.stubs(:code).returns 200
|
27
|
-
stub_response.stubs(:body).returns "Auth=dummy\n"
|
28
|
-
@klass.expects(:post).with('', @dummy_form).returns stub_response
|
29
|
-
@instance.token
|
30
|
-
end
|
24
|
+
describe "when posting" do
|
25
|
+
let(:response) { stub :response }
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@klass.expects(:post).with('', @dummy_form).returns stub_response
|
36
|
-
@instance.token.should be_nil
|
37
|
-
end
|
27
|
+
before :each do
|
28
|
+
klass.stubs(:post).with('', dummy_form).returns response
|
29
|
+
end
|
38
30
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
31
|
+
describe "invalid credentials" do
|
32
|
+
before do
|
33
|
+
response.stubs(:code).returns 403
|
34
|
+
end
|
35
|
+
|
36
|
+
its(:token) { should be_nil }
|
37
|
+
end
|
46
38
|
|
39
|
+
describe "valid credentials" do
|
40
|
+
before do
|
41
|
+
response.stubs(:code).returns 200
|
42
|
+
response.stubs(:body).returns "Auth=dummy\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
its(:token) { should == "dummy" }
|
46
|
+
end
|
47
|
+
end
|
47
48
|
end
|
@@ -2,58 +2,57 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe GProv::Connection do
|
4
4
|
|
5
|
-
|
6
|
-
@klass = GProv::Connection
|
7
|
-
@instance = @klass.new("domain", "token")
|
5
|
+
let(:klass) { GProv::Connection }
|
8
6
|
|
9
|
-
|
7
|
+
subject { GProv::Connection.new("domain", "token") }
|
8
|
+
|
9
|
+
let(:expected_options) do
|
10
|
+
{:headers => {
|
10
11
|
'Authorization' => "GoogleLogin auth=token",
|
11
12
|
'Content-Type' => 'application/atom+xml',
|
12
13
|
}}
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should use to google apps API url as the base uri" do
|
16
|
-
|
17
|
+
klass.base_uri.should == "https://apps-apis.google.com/a/feeds"
|
17
18
|
end
|
18
19
|
|
19
|
-
it
|
20
|
-
@instance.respond_to?(:domain).should == true
|
21
|
-
end
|
20
|
+
it { should respond_to :domain }
|
22
21
|
|
23
22
|
it "should expose the default headers" do
|
24
|
-
|
23
|
+
subject.default_headers.should == expected_options
|
25
24
|
end
|
26
25
|
|
27
26
|
|
28
27
|
describe "http instance method" do
|
29
28
|
[:put, :get, :post, :delete].each do |verb|
|
30
|
-
|
29
|
+
|
30
|
+
it { should respond_to verb }
|
31
|
+
|
32
|
+
describe "##{verb}" do
|
31
33
|
before do
|
32
|
-
xml = %Q{<?xml version="1.0" encoding="UTF-8"?>\n<test xml="pointy"/>}
|
34
|
+
xml = %Q{<?xml version="1.0" encoding="UTF-8"?>\n<test xml="pointy" />}
|
33
35
|
@stub_request = mock
|
34
36
|
@stub_request.stubs(:code).returns 200
|
35
37
|
@stub_request.stubs(:success?).returns true
|
36
38
|
@stub_request.stubs(:class).returns HTTParty::Response
|
37
39
|
end
|
38
40
|
|
39
|
-
it "should be an instance method" do
|
40
|
-
@instance.respond_to?(verb).should == true
|
41
|
-
end
|
42
41
|
|
43
42
|
it "should be forwarded to the class" do
|
44
|
-
|
45
|
-
|
43
|
+
klass.expects(verb).returns @stub_request
|
44
|
+
subject.send(verb, '')
|
46
45
|
end
|
47
46
|
|
48
47
|
it "should return the http response" do
|
49
|
-
|
50
|
-
output =
|
48
|
+
klass.expects(verb).returns @stub_request
|
49
|
+
output = subject.send(verb, "/url")
|
51
50
|
output.class.should == HTTParty::Response
|
52
51
|
end
|
53
52
|
|
54
53
|
it "should interpolate the :domain substring" do
|
55
|
-
|
56
|
-
|
54
|
+
klass.expects(verb).with("/domain", expected_options).returns @stub_request
|
55
|
+
subject.send(verb, "/:domain")
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -1,39 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'fakeentry'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
xml_attr_accessor :test, :xpath => "/foo/bar/text()"
|
6
|
-
xml_attr_accessor :test_transform, :xpath => "/foo/bar/text()", :transform => lambda {|x| x.upcase}
|
7
|
-
end
|
4
|
+
# Tests are against the fakeentry fixture
|
8
5
|
|
9
6
|
describe GProv::Provision::EntryBase do
|
10
7
|
|
11
|
-
before do
|
12
|
-
@klass = GProv::Provision::EntryBase
|
13
|
-
@test_klass = FakeEntry
|
14
|
-
@instance = @test_klass.new
|
15
|
-
end
|
16
|
-
|
17
|
-
describe GProv::Provision::EntryBase::ClassMethods do
|
18
|
-
|
19
|
-
[:xml_attr_accessor, :xml_to_hash, :attributes].each do |method|
|
20
|
-
it "method #{method} should be a class method" do
|
21
|
-
FakeEntry.respond_to?(method).should be_true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "xml_attr_accessor should receive a symbol and hash of attributes" do
|
26
|
-
@test_klass.attributes[:test].should == {:xpath => "/foo/bar/text()"}
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "xml_to_hash" do
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
8
|
[:status, :connection].each do |method|
|
35
|
-
it
|
36
|
-
@instance.respond_to?(method).should be_true
|
37
|
-
end
|
9
|
+
it { should respond_to method }
|
38
10
|
end
|
39
11
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gprov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adrien Thebo
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|
@@ -104,7 +104,12 @@ files:
|
|
104
104
|
- lib/gprov.rb
|
105
105
|
- spec/gprov/auth/clientlogin_spec.rb
|
106
106
|
- spec/gprov/connection_spec.rb
|
107
|
+
- spec/gprov/provision/entrybase/classmethods_spec.rb
|
107
108
|
- spec/gprov/provision/entrybase_spec.rb
|
109
|
+
- spec/gprov/provision/group.rb
|
110
|
+
- spec/gprov/provision/orgunit.rb
|
111
|
+
- spec/gprov/provision/user.rb
|
112
|
+
- spec/lib/fakeentry.rb
|
108
113
|
- spec/spec_helper.rb
|
109
114
|
- LICENSE
|
110
115
|
- Rakefile
|