provisioning-api 0.0.0

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,47 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
+ # use this file except in compliance with the License. You may obtain a copy of
5
+ # the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations under
13
+ # the License.
14
+ #
15
+ require 'net/https'
16
+ require 'cgi'
17
+
18
+ module GAppsProvisioning #:nodoc:
19
+ class Connection
20
+ attr_reader :http_connection
21
+
22
+ # Establishes SSL connection to Google host
23
+ def initialize(host, port, proxy=nil, proxy_port=nil, proxy_user=nil, proxy_passwd=nil)
24
+ conn = Net::HTTP.new(host, port, proxy, proxy_port, proxy_user, proxy_passwd)
25
+ conn.use_ssl = true
26
+ #conn.enable_post_connection_check= true
27
+ conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
28
+ #conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
+ # uncomment the previous line at your own risk : the certificate won't be verified !
30
+ store = OpenSSL::X509::Store.new
31
+ store.set_default_paths
32
+ conn.cert_store = store
33
+ conn.start
34
+ @http_connection = conn
35
+ end
36
+
37
+ # Performs the http request and returns the http response
38
+ def perform(method, path, body=nil, header=nil)
39
+ req = Net::HTTPGenericRequest.new(method, !body.nil?, true, path)
40
+ req['Content-Type'] = header['Content-Type'] if header['Content-Type']
41
+ req['Authorization'] = header['Authorization'] if header['Authorization']
42
+ req['Content-length'] = body.length.to_s if body
43
+ resp = @http_connection.request(req, body)
44
+ return resp
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
+ # use this file except in compliance with the License. You may obtain a copy of
5
+ # the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations under
13
+ # the License.
14
+ module GAppsProvisioning #:nodoc:
15
+
16
+ class GDataError < RuntimeError
17
+ attr_accessor :code, :input, :reason
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'provisioning-api'
3
+ s.version = '0.0.0'
4
+ s.date = '2011-10-19'
5
+ s.summary = "Google provisioning api ruby library"
6
+ s.description = "Google ruby library implementation of the provisioning API"
7
+ s.authors = ["Daniel Palacio"]
8
+ s.email = 'danpal@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
+ s.homepage ='http://www.authy.com'
12
+ end
13
+
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require 'provisioning-api'
5
+ require 'vcr'
6
+ include GAppsProvisioning
7
+
8
+
9
+ VCR.config do |c|
10
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
11
+ c.stub_with :fakeweb
12
+ end
13
+
14
+
15
+ describe ProvisioningApi do
16
+
17
+ before do
18
+ @adminuser = "admin@authysec.com"
19
+ @password = "input-password"
20
+ #VCR.turn_off!
21
+ end
22
+
23
+ describe "create user" do
24
+ it "should create a new user" do
25
+ VCR.use_cassette "create_user" do
26
+ myapps = ProvisioningApi.new(@adminuser,@password)
27
+ new_user = myapps.create_user("josmith", "john", "smith", "12345678")#username, givenname, familyname, password
28
+ end
29
+ end
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: provisioning-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Palacio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-19 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Google ruby library implementation of the provisioning API
15
+ email: danpal@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - .rvmrc
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - README.md
25
+ - Rakefile
26
+ - fixtures/vcr_cassettes/create_user.yml
27
+ - lib/provisioning-api.rb
28
+ - lib/provisioning-api/connection.rb
29
+ - lib/provisioning-api/exceptions.rb
30
+ - provisioning-api.gemspec
31
+ - test/test_provisioning_api.rb
32
+ homepage: http://www.authy.com
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.6
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Google provisioning api ruby library
56
+ test_files:
57
+ - test/test_provisioning_api.rb