oktakit 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbd3f20dc656f818547d543781eb2c61e02edfb4
4
- data.tar.gz: e85ac3df88311aa45c044d3164c3a0d9b1926c39
3
+ metadata.gz: c9ab3f2927fb37bff5e7f744fef1b776cea1e177
4
+ data.tar.gz: 14e391e87f55541c6ed309023e415e455e452486
5
5
  SHA512:
6
- metadata.gz: 31ce769f186c8a81b6fbc89d5ac6245f597e1ea9b076f98d2f33a0bb9e0d7dcfc20f2284130d6cd51051012f6ea05c69d0c0481090176f14ed540ea6d4b73a89
7
- data.tar.gz: a16ab920dce38e791b2ce923ee7f3385a163a1c72d32e9c8bdd021ee7a044ac968b60210d9eec8869606f78ec49c42a85a2d758f7322ddc4f84ba9b85e6e0f9e
6
+ metadata.gz: 60452d050ed044d24b3cc167ed21e785d6ac16afb728f88090355f637c9a794e9d9bb9cfb63d09ccbc3511f06a08ebad76350843df0c4f6556f854761e709839
7
+ data.tar.gz: f5e11f04ef1b29c96c7f4093ce6bc4c53abf2e3a7c470ce7e1af672cc9d5eb15b286504ffcb2c09af0a175b0dbbfe09cac98700f3d4ca1b39f0e186acfa6ca6a
data/README.md CHANGED
@@ -26,6 +26,12 @@ client = Oktakit.new(token: 't0k3n', organization: 'my-great-org')
26
26
  response, http_status = client.list_users
27
27
  ```
28
28
 
29
+ To work with the Okta sandbox (`<organization>.oktapreview.com`), set the `api_endpoint`:
30
+
31
+ ```ruby
32
+ client = Oktakit.new(token: 't0k3n', api_endpoint: 'https://my-great-org.oktapreview.com/api/v1')
33
+ ```
34
+
29
35
  #### Pagination
30
36
  Pass the `paginate` flag as options for any `get` action for Oktakit to autopaginate the response for you.
31
37
 
@@ -49,7 +55,7 @@ To anonymize the VCR data, first setup a real token and endpoint for Okta, such
49
55
  - Set the `OKTA_TEST_TOKEN` environment variable (this should be real). Don't worry, it is automatically removed.
50
56
  - Before committing, change `my-okta` to `okta-test` in `spec_helper.rb` and any VCR Cassettes.
51
57
 
52
- The [API Test Client](http://developer.okta.com/docs/api/getting_started/api_test_client) provided by Okta is also really helpful.
58
+ The [API Test Client](https://developer.okta.com/docs/api/getting_started/api_test_client) provided by Okta is also really helpful.
53
59
 
54
60
  ## Contributing
55
61
 
data/Rakefile CHANGED
@@ -7,13 +7,13 @@ require 'rubocop/rake_task'
7
7
  RuboCop::RakeTask.new
8
8
 
9
9
  task test: :spec
10
- task default: [:spec, :rubocop]
10
+ task default: %i[spec rubocop]
11
11
 
12
12
  namespace :doc do
13
13
  require 'yard'
14
14
  YARD::Rake::YardocTask.new do |task|
15
- task.files = %w(LICENSE.md lib/**/*.rb)
16
- task.options = %w(--output-dir doc/yard --markup markdown)
15
+ task.files = %w[LICENSE.md lib/**/*.rb]
16
+ task.options = %w[--output-dir doc/yard --markup markdown]
17
17
  end
18
18
  task default: :yard
19
19
  end
@@ -31,9 +31,22 @@ module Oktakit
31
31
  builder.adapter Faraday.default_adapter
32
32
  end
33
33
 
34
- def initialize(token:, organization:)
34
+ def initialize(token:, organization: nil, api_endpoint: nil)
35
+ if organization.nil? && api_endpoint.nil?
36
+ raise ArgumentError, "Please provide either the organization or the api_endpoint argument"
37
+ end
38
+
35
39
  @token = token
36
40
  @organization = organization
41
+ @api_endpoint = api_endpoint
42
+ end
43
+
44
+ def api_endpoint
45
+ if @api_endpoint
46
+ @api_endpoint
47
+ else
48
+ "https://#{@organization.downcase}.okta.com/api/v1"
49
+ end
37
50
  end
38
51
 
39
52
  # Make a HTTP GET request
@@ -160,7 +173,7 @@ module Oktakit
160
173
  options[:headers][:accept] = accept if accept
161
174
  options[:headers][:content_type] = content_type if content_type
162
175
 
163
- uri = URI::Parser.new.escape("/api/v1" + path.to_s)
176
+ uri = URI::DEFAULT_PARSER.escape("/api/v1" + path.to_s)
164
177
  @last_response = resp = sawyer_agent.call(method, uri, data, options)
165
178
 
166
179
  response = [resp.data, resp.status]
@@ -184,10 +197,6 @@ module Oktakit
184
197
  }
185
198
  end
186
199
 
187
- def api_endpoint
188
- "https://#{@organization}.okta.com/api/v1"
189
- end
190
-
191
200
  def absolute_to_relative_url(next_ref)
192
201
  return unless next_ref
193
202
  next_ref.href.sub(api_endpoint, '')
@@ -88,7 +88,7 @@ module Oktakit
88
88
  end
89
89
 
90
90
  def redact_url(url_string)
91
- %w(client_secret access_token).each do |token|
91
+ %w[client_secret access_token].each do |token|
92
92
  url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include? token
93
93
  end
94
94
  url_string
@@ -1,3 +1,3 @@
1
1
  module Oktakit
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'oktakit/version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oktakit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graeme Johnson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-05-23 00:00:00.000000000 Z
12
+ date: 2017-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sawyer
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.6.12
96
+ rubygems_version: 2.6.13
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Ruby toolkit for working with the Okta API