auth0 3.3.0 → 3.4.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: bdf4ecb5c96f5e84e45fc413f782f157ac5ac50d
4
- data.tar.gz: c3edbdcee08c40938fc43e97d836a779e3781b4d
3
+ metadata.gz: 8c8cbc5c686f482699408775f046cabd798eb6fb
4
+ data.tar.gz: 4876cce548226a3b7dcee445475d9be7621a159c
5
5
  SHA512:
6
- metadata.gz: f2931b8dfb4223dcb882351f995e51120378234642a59894fc271f441f886e68dfd41aaf4f653dd496b263a29fe6480e73210407f9a56997588776148676be08
7
- data.tar.gz: eb8796cfb3d8ceb57da9bae51b9499220dfc3e7f54511b5d4a5c232306c13dffad697577a56683367493305e9986d910887da6d7c37f6c29b3bfe0c0e159d96d
6
+ metadata.gz: 3b59e6938ee61772c70a87c275d88654507f4b419444d4e8332bd3ea18ebb7bca924d00ca27dd3fc358894391d59b3b05113d91c610b453775e1ae709eda1a3b
7
+ data.tar.gz: b9e0c9a9295e0db1197e44914ae23764d0c1d4caa698908ffa6e837dcbcba88776f4ed992522f75b9e1335fac87d19b73f863caf3407ab7695145129ccbefd9d
@@ -5,6 +5,7 @@ sudo: false
5
5
  cache: bundler
6
6
 
7
7
  rvm:
8
+ - 2.1.0
8
9
  - 2.2.1
9
10
 
10
- script: MODE=full bundle exec rake all
11
+ script: ./build_travis.sh
@@ -0,0 +1,81 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased](https://github.com/auth0/ruby-auth0/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v3.3.0...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Tag releases [\#16](https://github.com/auth0/ruby-auth0/issues/16)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - allow setting impersonation ttl [\#30](https://github.com/auth0/ruby-auth0/pull/30) ([seamusabshere](https://github.com/seamusabshere))
14
+
15
+ - Fix broken link in README [\#28](https://github.com/auth0/ruby-auth0/pull/28) ([dentarg](https://github.com/dentarg))
16
+
17
+ ## [v3.3.0](https://github.com/auth0/ruby-auth0/tree/v3.3.0) (2015-04-15)
18
+
19
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v3.2.0...v3.3.0)
20
+
21
+ **Closed issues:**
22
+
23
+ - AuthenticationEndpoints should be independent of the V1/V2 API [\#20](https://github.com/auth0/ruby-auth0/issues/20)
24
+
25
+ - Typo in AuthenticationEndpoints.login [\#17](https://github.com/auth0/ruby-auth0/issues/17)
26
+
27
+ - Remove generated docs [\#14](https://github.com/auth0/ruby-auth0/issues/14)
28
+
29
+ - Remove the examples directory from this repository [\#4](https://github.com/auth0/ruby-auth0/issues/4)
30
+
31
+ **Merged pull requests:**
32
+
33
+ - Chore integration tests [\#27](https://github.com/auth0/ruby-auth0/pull/27) ([hzalaz](https://github.com/hzalaz))
34
+
35
+ - allow to pass extra parameters to delegation method [\#23](https://github.com/auth0/ruby-auth0/pull/23) ([Maxim-Filimonov](https://github.com/Maxim-Filimonov))
36
+
37
+ ## [v3.2.0](https://github.com/auth0/ruby-auth0/tree/v3.2.0) (2015-04-14)
38
+
39
+ **Merged pull requests:**
40
+
41
+ - Impersonation [\#26](https://github.com/auth0/ruby-auth0/pull/26) ([dentarg](https://github.com/dentarg))
42
+
43
+ - Allow to set api\_type to use with salesforce\_api [\#25](https://github.com/auth0/ruby-auth0/pull/25) ([Maxim-Filimonov](https://github.com/Maxim-Filimonov))
44
+
45
+ - Fixed few issues from issues list [\#22](https://github.com/auth0/ruby-auth0/pull/22) ([offtop](https://github.com/offtop))
46
+
47
+ - Update readme.md api v2 basic usage example [\#19](https://github.com/auth0/ruby-auth0/pull/19) ([ethancrawford](https://github.com/ethancrawford))
48
+
49
+ - fix token initialization to prevent nil token value [\#18](https://github.com/auth0/ruby-auth0/pull/18) ([ethancrawford](https://github.com/ethancrawford))
50
+
51
+ - Make the client work for API v1 [\#13](https://github.com/auth0/ruby-auth0/pull/13) ([dentarg](https://github.com/dentarg))
52
+
53
+ - Fix typo delegation signature; open\_id =\> openid [\#12](https://github.com/auth0/ruby-auth0/pull/12) ([dentarg](https://github.com/dentarg))
54
+
55
+ - Make the tests run on Travis CI [\#11](https://github.com/auth0/ruby-auth0/pull/11) ([dentarg](https://github.com/dentarg))
56
+
57
+ - Added support for API V1 and API V2 [\#9](https://github.com/auth0/ruby-auth0/pull/9) ([offtop](https://github.com/offtop))
58
+
59
+ - Update README.md [\#8](https://github.com/auth0/ruby-auth0/pull/8) ([pose](https://github.com/pose))
60
+
61
+ - Make delete user safe [\#5](https://github.com/auth0/ruby-auth0/pull/5) ([dentarg](https://github.com/dentarg))
62
+
63
+ - Remove the omniauth strategy [\#3](https://github.com/auth0/ruby-auth0/pull/3) ([dentarg](https://github.com/dentarg))
64
+
65
+ - Fix rspec deprecation warning [\#2](https://github.com/auth0/ruby-auth0/pull/2) ([dentarg](https://github.com/dentarg))
66
+
67
+ - Add method to access delegation endpoint [\#1](https://github.com/auth0/ruby-auth0/pull/1) ([FrancisPlaza](https://github.com/FrancisPlaza))
68
+
69
+ - Authendpoint in v2 [\#24](https://github.com/auth0/ruby-auth0/pull/24) ([Maxim-Filimonov](https://github.com/Maxim-Filimonov))
70
+
71
+ - make AuthenticationEndpoints available to client in v2 mode [\#21](https://github.com/auth0/ruby-auth0/pull/21) ([MungoH](https://github.com/MungoH))
72
+
73
+ - updated webmock version, updated documentation [\#10](https://github.com/auth0/ruby-auth0/pull/10) ([offtop](https://github.com/offtop))
74
+
75
+ - Add create user method [\#7](https://github.com/auth0/ruby-auth0/pull/7) ([dentarg](https://github.com/dentarg))
76
+
77
+ - Add impersonation method [\#6](https://github.com/auth0/ruby-auth0/pull/6) ([dentarg](https://github.com/dentarg))
78
+
79
+
80
+
81
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -70,8 +70,8 @@ If you have found a bug or if you have a feature request, please report them at
70
70
 
71
71
  ## Author
72
72
 
73
- [Auth0](auth0.com)
73
+ [Auth0](https://auth0.com)
74
74
 
75
75
  ## License
76
76
 
77
- This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
77
+ This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
data/Rakefile CHANGED
@@ -2,23 +2,23 @@
2
2
  require "bundler/gem_tasks"
3
3
 
4
4
  begin
5
- require 'rspec/core/rake_task'
5
+ require 'rspec/core/rake_task'
6
6
 
7
- desc "Run Integration Tests"
8
- RSpec::Core::RakeTask.new(:integration) do |t|
9
- t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
10
- end
7
+ desc "Run Integration Tests"
8
+ RSpec::Core::RakeTask.new(:integration) do |t|
9
+ t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
10
+ end
11
11
 
12
12
 
13
- desc "Run Unit Tests"
14
- RSpec::Core::RakeTask.new(:spec) do |t|
15
- t.pattern = FileList["spec/lib/auth0/**/*#{ENV['PATTERN']}*_spec.rb"]
16
- end
13
+ desc "Run Unit Tests"
14
+ RSpec::Core::RakeTask.new(:spec) do |t|
15
+ t.pattern = FileList["spec/lib/auth0/**/*#{ENV['PATTERN']}*_spec.rb"]
16
+ end
17
17
 
18
- desc "Run All Suites"
19
- RSpec::Core::RakeTask.new(:all)
18
+ desc "Run All Suites"
19
+ RSpec::Core::RakeTask.new(:all)
20
20
 
21
- task :default => :spec
21
+ task :default => :spec
22
22
  rescue LoadError
23
- #No RSpec
24
- end
23
+ #No RSpec
24
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then
4
+ MODE=full bundle exec rake all
5
+ else
6
+ bundle exec rake spec
7
+ fi
@@ -6,9 +6,9 @@ module Auth0
6
6
  # {https://auth0.com/docs/auth-api#!#post--oauth-access_token}
7
7
  def obtain_access_token
8
8
  request_params = {
9
- client_id: @client_id,
10
- client_secret: @client_secret,
11
- grant_type: 'client_credentials'
9
+ client_id: @client_id,
10
+ client_secret: @client_secret,
11
+ grant_type: 'client_credentials'
12
12
  }
13
13
  post("/oauth/token", request_params)["access_token"]
14
14
  end
@@ -16,12 +16,12 @@ module Auth0
16
16
  # {https://auth0.com/docs/auth-api#!#post--delegation}
17
17
  def delegation(id_token, target, scope = "openid", api_type = "app", extra_parameters = {})
18
18
  request_params = {
19
- client_id: @client_id,
20
- grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
21
- id_token: id_token,
22
- target: target,
23
- api_type: api_type,
24
- scope: scope
19
+ client_id: @client_id,
20
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
21
+ id_token: id_token,
22
+ target: target,
23
+ api_type: api_type,
24
+ scope: scope
25
25
  }.merge(extra_parameters)
26
26
  post("/delegation", request_params)
27
27
  end
@@ -32,6 +32,7 @@ module Auth0
32
32
  protocol: options.fetch(:protocol, "oauth2"),
33
33
  impersonator_id: impersonator_id,
34
34
  client_id: app_client_id,
35
+ ttl: options.fetch(:ttl, 120),
35
36
  additionalParameters: {
36
37
  response_type: options.fetch(:response_type, "code"),
37
38
  state: options.fetch(:state, ""),
@@ -15,9 +15,9 @@ module Auth0
15
15
  def create_client(name, callbacks="")
16
16
  path = "/api/clients"
17
17
  request_params = {
18
- name: name,
19
- callbacks: callbacks
20
- }
18
+ name: name,
19
+ callbacks: callbacks
20
+ }
21
21
  post(path, request_params)
22
22
  end
23
23
 
@@ -27,9 +27,9 @@ module Auth0
27
27
  warn "This endpoint has been deprecated in favor of PATCH."
28
28
  path = "/api/clients/#{client_id}"
29
29
  request_params = {
30
- name: name,
31
- callbacks: callbacks
32
- }
30
+ name: name,
31
+ callbacks: callbacks
32
+ }
33
33
  put(path, request_params)
34
34
  end
35
35
 
@@ -37,9 +37,9 @@ module Auth0
37
37
  def patch_client(name, callbacks="", client_id=@client_id)
38
38
  path = "/api/clients/#{client_id}"
39
39
  request_params = {
40
- name: name,
41
- callbacks: callbacks
42
- }
40
+ name: name,
41
+ callbacks: callbacks
42
+ }
43
43
  patch(path, request_params)
44
44
  end
45
45
  end
@@ -25,24 +25,26 @@ module Auth0
25
25
  # {https://auth0.com/docs/api#!#post--api-connections}
26
26
  def create_connection(connection_name, strategy, tenant_domain, domain_aliases=nil)
27
27
  path = "/api/connections"
28
- request_params = { name: connection_name,
29
- strategy: strategy,
30
- options: {
31
- tenant_domain: tenant_domain,
32
- domain_aliases: domain_aliases
33
- }
34
- }
28
+ request_params = {
29
+ name: connection_name,
30
+ strategy: strategy,
31
+ options: {
32
+ tenant_domain: tenant_domain,
33
+ domain_aliases: domain_aliases
34
+ }
35
+ }
35
36
  post(path, request_params)
36
37
  end
37
38
 
38
39
  # {https://auth0.com/docs/api#!#put--api-connections--connection-name-}
39
40
  def update_connection(connection_name, tenant_domain, status=true)
40
41
  path = "/api/connections/#{connection_name}"
41
- request_params = { status: status,
42
- options: {
43
- tenant_domain: tenant_domain
44
- }
45
- }
42
+ request_params = {
43
+ status: status,
44
+ options: {
45
+ tenant_domain: tenant_domain
46
+ }
47
+ }
46
48
  put(path, request_params)
47
49
  end
48
50
  end
@@ -12,8 +12,8 @@ module Auth0
12
12
  acceptable_params = %i(take from search_criteria page per_page sort fields exclude_fields)
13
13
  options.reject! do |key,value|
14
14
  if key.nil? ||\
15
- value.nil? ||\
16
- !acceptable_params.include?(key.to_sym)
15
+ value.nil? ||\
16
+ !acceptable_params.include?(key.to_sym)
17
17
  warn "#{key} is not in acceptable params list: #{acceptable_params}"
18
18
  true
19
19
  end
@@ -14,11 +14,12 @@ module Auth0
14
14
  # https://auth0.com/docs/api#!#post--api-rules
15
15
  def create_rule(name, script, order=nil,status=true)
16
16
  path = "/api/rules"
17
- request_params = { name: name,
18
- status: status,
19
- script: script,
20
- order: order
21
- }
17
+ request_params = {
18
+ name: name,
19
+ status: status,
20
+ script: script,
21
+ order: order
22
+ }
22
23
  post(path, request_params)
23
24
  end
24
25
 
@@ -26,10 +27,10 @@ module Auth0
26
27
  def update_rule(name, script, order=nil,status=true)
27
28
  path = "/api/rules/#{name}"
28
29
  request_params = {
29
- status: status,
30
- script: script,
31
- order: order
32
- }
30
+ status: status,
31
+ script: script,
32
+ order: order
33
+ }
33
34
  put(path, request_params)
34
35
  end
35
36
 
@@ -5,15 +5,16 @@ module Auth0
5
5
  module Users
6
6
  #https://auth0.com/docs/apiv2#!/users/get_users
7
7
  def users( per_page: nil, page: nil, include_totals: nil, sort: nil, connection: nil, fields: nil, exclude_fields: nil, q: nil )
8
- request_params = { per_page: per_page,
9
- page: page,
10
- include_totals: include_totals,
11
- sort: sort,
12
- connection: connection,
13
- fields: fields,
14
- exclude_fields: exclude_fields,
15
- q: q
16
- }
8
+ request_params = {
9
+ per_page: per_page,
10
+ page: page,
11
+ include_totals: include_totals,
12
+ sort: sort,
13
+ connection: connection,
14
+ fields: fields,
15
+ exclude_fields: exclude_fields,
16
+ q: q
17
+ }
17
18
  path = "/api/v2/users"
18
19
  get(path, request_params)
19
20
  end
@@ -36,9 +37,10 @@ module Auth0
36
37
  #https://auth0.com/docs/apiv2#!/users/get_users_by_id
37
38
  def user(user_id, fields: nil, exclude_fields: nil)
38
39
  path = "/api/v2/users/" + user_id.to_s
39
- request_params = { fields: fields,
40
- exclude_fields: exclude_fields
41
- }
40
+ request_params = {
41
+ fields: fields,
42
+ exclude_fields: exclude_fields
43
+ }
42
44
  get(path, request_params)
43
45
  end
44
46
 
@@ -23,4 +23,4 @@ class Auth0::InvalidParameter < Auth0::Exception; end
23
23
  # Invalid Auth0 credentials either client_id/secret for API v1 or JWT for API v2/
24
24
  class Auth0::InvalidCredentials < Auth0::Exception; end
25
25
  # Invalid Auth0 API namespace
26
- class Auth0::InvalidApiNamespace < Auth0::Exception; end
26
+ class Auth0::InvalidApiNamespace < Auth0::Exception; end
@@ -13,11 +13,11 @@ module Auth0
13
13
  result = self.class.send(method, safe_path, body: body.to_json)
14
14
  end
15
15
  response_body =
16
- begin
17
- JSON.parse(result.body.to_s)
18
- rescue JSON::ParserError
19
- result.body
20
- end
16
+ begin
17
+ JSON.parse(result.body.to_s)
18
+ rescue JSON::ParserError
19
+ result.body
20
+ end
21
21
  case result.code
22
22
  when 200...226 then response_body
23
23
  when 400 then raise Auth0::BadRequest, response_body
@@ -1,4 +1,4 @@
1
1
  module Auth0
2
2
  # current version of gem
3
- VERSION = "3.3.0"
3
+ VERSION = "3.4.0"
4
4
  end
@@ -3,11 +3,12 @@ describe Auth0::Api::V1::Clients do
3
3
 
4
4
  let(:client) { Auth0Client.new(v1_creds) }
5
5
  let(:global_client) { Auth0Client.new(v1_global_creds) }
6
-
6
+ let(:client_name) { "client#{entity_suffix}" }
7
+
7
8
  it { expect(client.clients).to_not be_empty }
8
9
 
9
- it { expect {client.create_client("client")}.to raise_error(Auth0::Unauthorized) }
10
+ it { expect {client.create_client(client_name)}.to raise_error(Auth0::Unauthorized) }
10
11
 
11
- it { expect(global_client.create_client("client")).to_not be_nil }
12
+ it { expect(global_client.create_client(client_name)).to_not be_nil }
12
13
 
13
14
  end
@@ -3,7 +3,7 @@ describe Auth0::Api::V1::Users do
3
3
 
4
4
  let(:client) { Auth0Client.new(v1_creds) }
5
5
  let(:username) { Faker::Internet.user_name }
6
- let(:email) { Faker::Internet.safe_email }
6
+ let(:email) { Faker::Internet.safe_email("#{username}#{entity_suffix}") }
7
7
  let(:password) { Faker::Internet.password }
8
8
  let(:connection) { "Username-Password-Authentication" }
9
9
  let!(:user) { client.create_user(email, password, connection, {
@@ -2,11 +2,12 @@ require "spec_helper"
2
2
  describe Auth0::Api::V2::Clients do
3
3
 
4
4
  let(:client) { Auth0Client.new(v2_creds) }
5
- let(:existing_client) { client.create_client("existing") }
6
-
5
+ let(:existing_client) { client.create_client("existing#{entity_suffix}") }
6
+ let(:client_name) { "ClientV2#{entity_suffix}" }
7
+
7
8
  it { expect(client.clients).to_not be_empty }
8
9
 
9
- it { expect(client.create_client("ClientV2", {custom_login_page_off: true})).to include("name" => "ClientV2", "custom_login_page_off" => true) }
10
+ it { expect(client.create_client(client_name, {custom_login_page_off: true})).to include("name" => client_name, "custom_login_page_off" => true) }
10
11
 
11
12
  it { expect(client.patch_client(existing_client["client_id"], {custom_login_page_off: true, sso: true})).to include("custom_login_page_off" => true, "sso" => true) }
12
13
 
@@ -3,16 +3,16 @@ describe Auth0::Api::V2::Users do
3
3
 
4
4
  let(:client) { Auth0Client.new(v2_creds) }
5
5
  let(:username) { Faker::Internet.user_name }
6
- let(:email) { Faker::Internet.safe_email }
6
+ let(:email) { Faker::Internet.safe_email("#{username}#{entity_suffix}") }
7
7
  let(:password) { Faker::Internet.password }
8
8
  let(:connection) { "Username-Password-Authentication" }
9
9
  let!(:user) { client.create_user(username, {
10
- "username" => username,
11
- "email" => email,
12
- "password" => password,
13
- "email_verified" => false,
14
- "connection" => connection,
15
- "app_metadata" => {}
10
+ "username" => username,
11
+ "email" => email,
12
+ "password" => password,
13
+ "email_verified" => false,
14
+ "connection" => connection,
15
+ "app_metadata" => {}
16
16
  })}
17
17
 
18
18
  describe '.users' do
@@ -48,10 +48,10 @@ describe Auth0::Api::V2::Users do
48
48
  let(:subject) { user }
49
49
 
50
50
  it { should include("user_id", "identities") }
51
- it { should include(
52
- "username" => username,
53
- "email" => email,
54
- "email_verified" => false,
51
+ it { should include(
52
+ "username" => username,
53
+ "email" => email,
54
+ "email_verified" => false,
55
55
  )}
56
56
 
57
57
  end
@@ -1,45 +1,45 @@
1
1
  require "spec_helper"
2
2
  describe Auth0::Client do
3
3
 
4
- shared_examples "invalid credentials" do |credentials, error|
5
- it "raise an error with credentials #{credentials}" do
6
- if error.nil?
7
- expect { Auth0Client.new(credentials) }.to raise_error
8
- else
9
- expect { Auth0Client.new(credentials) }.to raise_error(error)
10
- end
11
- end
12
- end
4
+ shared_examples "invalid credentials" do |credentials, error|
5
+ it "raise an error with credentials #{credentials}" do
6
+ if error.nil?
7
+ expect { Auth0Client.new(credentials) }.to raise_error
8
+ else
9
+ expect { Auth0Client.new(credentials) }.to raise_error(error)
10
+ end
11
+ end
12
+ end
13
13
 
14
- it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com"}, Auth0::InvalidCredentials
15
- it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", client_id: "client_id"}, Auth0::InvalidCredentials
16
- it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", client_secret: "secret"}, Auth0::InvalidCredentials
17
- it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", api_version: 2}, Auth0::InvalidCredentials
18
- it_should_behave_like "invalid credentials", {}
19
- it_should_behave_like "invalid credentials", {api_version: 2}
20
- it_should_behave_like "invalid credentials", {api_version: 1}
21
- it_should_behave_like "invalid credentials", {client_id: "client_id", client_secret: "secret"}, Auth0::InvalidApiNamespace
22
- it_should_behave_like "invalid credentials", {api_version: 2, token: "token"}, Auth0::InvalidApiNamespace
14
+ it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com"}, Auth0::InvalidCredentials
15
+ it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", client_id: "client_id"}, Auth0::InvalidCredentials
16
+ it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", client_secret: "secret"}, Auth0::InvalidCredentials
17
+ it_should_behave_like "invalid credentials", {namespace: "samples.auth0.com", api_version: 2}, Auth0::InvalidCredentials
18
+ it_should_behave_like "invalid credentials", {}
19
+ it_should_behave_like "invalid credentials", {api_version: 2}
20
+ it_should_behave_like "invalid credentials", {api_version: 1}
21
+ it_should_behave_like "invalid credentials", {client_id: "client_id", client_secret: "secret"}, Auth0::InvalidApiNamespace
22
+ it_should_behave_like "invalid credentials", {api_version: 2, token: "token"}, Auth0::InvalidApiNamespace
23
23
 
24
- let(:valid_v1_credentials) { {client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"], domain: ENV["DOMAIN"]} }
25
- let(:token) { ENV["MASTER_JWT"] }
26
- let(:v2_credentials) { {domain: ENV["DOMAIN"], api_version: 2} }
27
-
28
- shared_examples "valid credentials" do
29
- it { expect { Auth0Client.new(credentials) }.to_not raise_error }
30
- end
24
+ let(:valid_v1_credentials) { {client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"], domain: ENV["DOMAIN"]} }
25
+ let(:token) { ENV["MASTER_JWT"] }
26
+ let(:v2_credentials) { {domain: ENV["DOMAIN"], api_version: 2} }
31
27
 
32
- it_should_behave_like "valid credentials" do
33
- let(:credentials) { valid_v1_credentials }
34
- end
35
- it_should_behave_like "valid credentials" do
36
- let(:credentials) { valid_v1_credentials.merge({api_version: 1}) }
37
- end
38
- it_should_behave_like "valid credentials" do
39
- let(:credentials) { v2_credentials.merge({token: token})}
40
- end
41
- it_should_behave_like "valid credentials" do
42
- let(:credentials) { v2_credentials.merge({access_token: ENV["MASTER_JWT"]}) }
43
- end
28
+ shared_examples "valid credentials" do
29
+ it { expect { Auth0Client.new(credentials) }.to_not raise_error }
30
+ end
44
31
 
45
- end
32
+ it_should_behave_like "valid credentials" do
33
+ let(:credentials) { valid_v1_credentials }
34
+ end
35
+ it_should_behave_like "valid credentials" do
36
+ let(:credentials) { valid_v1_credentials.merge({api_version: 1}) }
37
+ end
38
+ it_should_behave_like "valid credentials" do
39
+ let(:credentials) { v2_credentials.merge({token: token})}
40
+ end
41
+ it_should_behave_like "valid credentials" do
42
+ let(:credentials) { v2_credentials.merge({access_token: ENV["MASTER_JWT"]}) }
43
+ end
44
+
45
+ end
@@ -43,7 +43,7 @@ describe Auth0::Api::AuthenticationEndpoints do
43
43
 
44
44
  it {expect(@instance).to respond_to(:impersonate)}
45
45
  it "is expected to make post request to '/users/{user_id}/impersonate'" do
46
- expect(@instance).to receive(:post).with("/users/#{user_id}/impersonate",{:protocol=>"oauth2", :impersonator_id=>impersonator_id, :client_id=>app_client_id, :additionalParameters=>{:response_type=>"code", :state=>"", :scope=>"openid", :callback_url=>""}})
46
+ expect(@instance).to receive(:post).with("/users/#{user_id}/impersonate",{:protocol=>"oauth2", :impersonator_id=>impersonator_id, :client_id=>app_client_id, :ttl=>120, :additionalParameters=>{:response_type=>"code", :state=>"", :scope=>"openid", :callback_url=>""}})
47
47
  @instance.impersonate(user_id, app_client_id, impersonator_id, {})
48
48
  end
49
49
  end
@@ -47,7 +47,7 @@ describe Auth0::Client do
47
47
  before :each do
48
48
  allow_any_instance_of(Auth0::Api::AuthenticationEndpoints).to receive(:obtain_access_token).and_return "token"
49
49
  end
50
-
50
+
51
51
  context "with namespace" do
52
52
 
53
53
  let(:subject) { Auth0::Client.new(client_id: "client_id", client_secret: "client_secret", namespace: "samples.auth0.com") }
@@ -67,7 +67,7 @@ describe Auth0::Client do
67
67
  end
68
68
 
69
69
  context "with version" do
70
-
70
+
71
71
  let(:subject) { Auth0::Client.new(client_id: "client_id", client_secret: "client_secret", domain: "samples.auth0.com", api_version: 1) }
72
72
 
73
73
  it_should_behave_like "v1 API client"
@@ -102,7 +102,7 @@ describe Auth0::Client do
102
102
  end
103
103
 
104
104
  context "with version" do
105
-
105
+
106
106
  let(:subject) { Auth0::Client.new(api_version: 2, access_token: "access_token", domain: "samples.auth0.com") }
107
107
 
108
108
  it_should_behave_like "v2 API client"
@@ -19,15 +19,22 @@ require 'pry'
19
19
  Dir[("./lib/**/*.rb")].each { |f| require f }
20
20
  Dir[("./spec/support/**/*.rb")].each { |f| require f }
21
21
 
22
+ def entity_suffix
23
+ ENV["TRAVIS_BUILD_ID"] || "_local"
24
+ end
25
+
22
26
  RSpec.configure do |config|
23
- config.include Rack::Test::Methods
27
+ config.include Rack::Test::Methods
24
28
  config.include Credentials
25
29
  config.after(:suite) do
26
30
  v2_client = Auth0Client.new({token: ENV["MASTER_JWT"], api_version: 2, domain: ENV["DOMAIN"]})
27
31
  v2_client
28
32
  .clients
29
- .select { |client| client["name"] != "DefaultApp" and not client["global"] }
33
+ .select { |client| client["name"] != "DefaultApp" and not client["global"] and client["name"].end_with? entity_suffix }
30
34
  .each { |client| v2_client.delete_client(client["client_id"]) }
31
- v2_client.delete_users
35
+ v2_client
36
+ .users
37
+ .select { |user| user["email"].split("@").first.include? entity_suffix }
38
+ .each { |user| v2_client.delete_user(user["user_id"])}
32
39
  end
33
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth0
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Auth0
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-04-15 00:00:00.000000000 Z
14
+ date: 2015-05-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
@@ -213,12 +213,14 @@ files:
213
213
  - ".gitignore"
214
214
  - ".rspec"
215
215
  - ".travis.yml"
216
+ - CHANGELOG.md
216
217
  - Gemfile
217
218
  - Guardfile
218
219
  - LICENSE
219
220
  - README.md
220
221
  - Rakefile
221
222
  - auth0.gemspec
223
+ - build_travis.sh
222
224
  - lib/auth0.rb
223
225
  - lib/auth0/api/authentication_endpoints.rb
224
226
  - lib/auth0/api/v1.rb