usergrid_iron 0.9.0 → 0.9.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a5ce20bdc1101ec6c707b74c0c15420c9d650e9
4
+ data.tar.gz: 94b8e5bf5dd301366b8c46e7d60ad09b26620f56
5
+ SHA512:
6
+ metadata.gz: 30062931f1ef4831031e4e593d2a57fd77c668c065427ff2ddfbc2eefbc317de51edb7e258e78b1a84daa17fbdf27069420d61d329827abb24d639edd5ac5836
7
+ data.tar.gz: 26cdaa41b63d02d05dad639e4177b6179588ed64cf5fc05929ab17945c6a8753ab2fafcf4cc0ad26b2161b106ac1695f7935f23f67608351d49122da46e9774e
data/README.md CHANGED
@@ -181,6 +181,10 @@ usergrid_iron/spec/spec_settings.yaml to match.)
181
181
 
182
182
  ## Release notes
183
183
 
184
+ ### 0.9.1
185
+ * New features
186
+ 1. may now login using credentials: application.login_credentials() or organization.login_credentials()
187
+
184
188
  ### 0.9.0
185
189
  * Backend changes
186
190
  1. login function now uses POST instead of GET
@@ -48,6 +48,10 @@ module Usergrid
48
48
  response
49
49
  end
50
50
 
51
+ def login_credentials(client_id, client_secret)
52
+ response = self['token'].post grant_type: 'client_credentials', client_id: client_id, client_secret: client_secret
53
+ self.auth_token = response.data['access_token']
54
+ end
51
55
 
52
56
  private
53
57
 
@@ -49,5 +49,11 @@ module Usergrid
49
49
  self['credentials'].post nil
50
50
  end
51
51
 
52
+ def login_credentials(client_id, client_secret)
53
+ resource = api_resource 'management'
54
+ response = resource['token'].post grant_type: 'client_credentials', client_id: client_id, client_secret: client_secret
55
+ self.auth_token = response.data['access_token']
56
+ end
57
+
52
58
  end
53
59
  end
@@ -1,3 +1,3 @@
1
1
  module Usergrid
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -66,3 +66,9 @@ def create_random_user(application, login=false)
66
66
  application.login user_hash[:username], user_hash[:password] if login
67
67
  entity
68
68
  end
69
+
70
+ RSpec.configure do |config|
71
+ config.filter_run focus: true
72
+ config.run_all_when_everything_filtered = true
73
+ config.treat_symbols_as_metadata_keys_with_true_values = true
74
+ end
@@ -294,4 +294,34 @@ describe Usergrid::Application do
294
294
  entities.size.should eq 1
295
295
  end
296
296
 
297
+ describe "grant_type: client_credentials" do
298
+
299
+ before(:each) do
300
+ @app = create_random_application
301
+ end
302
+
303
+ context "invalid credentials" do
304
+ it "should not be able to get access token with invalid credentials" do
305
+ expect { @app.login_credentials "invalid_client_id", "invalid_client_secret" }.to raise_exception RestClient::BadRequest
306
+ end
307
+
308
+ it "should not be able to get access token with empty credentials" do
309
+ expect { @app.login_credentials "", "" }.to raise_exception RestClient::BadRequest
310
+ end
311
+ end
312
+
313
+ context "valid credentials" do
314
+ it "should be able to get access token with valid credentials" do
315
+ app_info = JSON.parse @app.get
316
+
317
+ management = login_management
318
+ app = management.application app_info["organization"], app_info["applicationName"]
319
+ app_credentials = JSON.parse app.credentials
320
+ app.login_credentials app_credentials["credentials"]["client_id"], app_credentials["credentials"]["client_secret"]
321
+
322
+ expect(app.auth_token).to_not be_empty
323
+ expect(app.auth_token).to be_instance_of String
324
+ end
325
+ end
326
+ end
297
327
  end
@@ -1,6 +1,6 @@
1
1
  describe Usergrid::Organization do
2
2
 
3
- before :all do
3
+ before :each do
4
4
  @management = Usergrid::Resource.new(SPEC_SETTINGS[:api_url]).management
5
5
  @management.login SPEC_SETTINGS[:organization][:username], SPEC_SETTINGS[:organization][:password]
6
6
  @organization = @management.organization SPEC_SETTINGS[:organization][:name]
@@ -69,4 +69,30 @@ describe Usergrid::Organization do
69
69
  response.data.credentials.client_secret.should_not be_nil
70
70
  end
71
71
 
72
+ describe "grant_type: client_credentials" do
73
+ context "invalid credentials" do
74
+ before :each do
75
+ @organization.logout
76
+ end
77
+
78
+ it "should not be able to get access token with invalid credentials" do
79
+ expect { @organization.login_credentials "invalid_client_id", "invalid_client_secret" }.to raise_exception RestClient::BadRequest
80
+ end
81
+
82
+ it "should not be able to get access token with empty credentials" do
83
+ expect { @organization.login_credentials "", "" }.to raise_exception RestClient::BadRequest
84
+ end
85
+ end
86
+
87
+ context "valid crendentials" do
88
+ it "should be able to get access token with valid credentials" do
89
+ org_credentials = JSON.parse @organization.credentials
90
+ @organization.logout
91
+ @organization.login_credentials org_credentials["credentials"]["client_id"], org_credentials["credentials"]["client_secret"]
92
+
93
+ expect(@organization.auth_token).to_not be_empty
94
+ expect(@organization.auth_token).to be_instance_of String
95
+ end
96
+ end
97
+ end
72
98
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usergrid_iron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
5
- prerelease:
4
+ version: 0.9.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Scott Ganyo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
11
+ date: 2013-05-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: simplecov
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Low-level gem to access Usergrid / Apigee App Services
@@ -137,33 +126,26 @@ files:
137
126
  - usergrid_iron.gemspec
138
127
  homepage: https://github.com/scottganyo/usergrid_iron
139
128
  licenses: []
129
+ metadata: {}
140
130
  post_install_message:
141
131
  rdoc_options: []
142
132
  require_paths:
143
133
  - lib
144
134
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
135
  requirements:
147
- - - ! '>='
136
+ - - '>='
148
137
  - !ruby/object:Gem::Version
149
138
  version: '0'
150
- segments:
151
- - 0
152
- hash: -824551858542229822
153
139
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
140
  requirements:
156
- - - ! '>='
141
+ - - '>='
157
142
  - !ruby/object:Gem::Version
158
143
  version: '0'
159
- segments:
160
- - 0
161
- hash: -824551858542229822
162
144
  requirements: []
163
145
  rubyforge_project:
164
- rubygems_version: 1.8.24
146
+ rubygems_version: 2.0.3
165
147
  signing_key:
166
- specification_version: 3
148
+ specification_version: 4
167
149
  summary: Usergrid_iron enables simple, low-level Ruby access to Apigee's App Services
168
150
  (aka Usergrid) REST API with minimal dependencies.
169
151
  test_files: