auth0 3.6.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +7 -0
  5. data/.travis.yml +12 -7
  6. data/CHANGELOG.md +10 -0
  7. data/Gemfile +4 -2
  8. data/Guardfile +13 -10
  9. data/LICENSE +2 -2
  10. data/README.md +9 -11
  11. data/Rakefile +33 -7
  12. data/auth0.gemspec +12 -12
  13. data/deploy_documentation.sh +29 -0
  14. data/doc_config/templates/default/fulldoc/html/css/full_list.css +79 -0
  15. data/doc_config/templates/default/fulldoc/html/css/style.css +546 -0
  16. data/doc_config/templates/default/layout/html/breadcrumb.erb +11 -0
  17. data/doc_config/templates/default/layout/html/footer.erb +115 -0
  18. data/doc_config/templates/default/layout/html/headers.erb +17 -0
  19. data/doc_config/templates/default/layout/html/layout.erb +27 -0
  20. data/lib/auth0.rb +5 -5
  21. data/lib/auth0/api/authentication_endpoints.rb +264 -46
  22. data/lib/auth0/api/v1.rb +5 -5
  23. data/lib/auth0/api/v1/clients.rb +7 -7
  24. data/lib/auth0/api/v1/connections.rb +9 -10
  25. data/lib/auth0/api/v1/logs.rb +9 -16
  26. data/lib/auth0/api/v1/rules.rb +5 -5
  27. data/lib/auth0/api/v1/users.rb +28 -27
  28. data/lib/auth0/api/v2.rb +17 -9
  29. data/lib/auth0/api/v2/blacklists.rb +30 -9
  30. data/lib/auth0/api/v2/clients.rb +60 -19
  31. data/lib/auth0/api/v2/connections.rb +63 -10
  32. data/lib/auth0/api/v2/emails.rb +58 -0
  33. data/lib/auth0/api/v2/jobs.rb +44 -7
  34. data/lib/auth0/api/v2/rules.rb +104 -0
  35. data/lib/auth0/api/v2/stats.rb +22 -5
  36. data/lib/auth0/api/v2/tenants.rb +39 -0
  37. data/lib/auth0/api/v2/tickets.rb +58 -0
  38. data/lib/auth0/api/v2/users.rb +128 -39
  39. data/lib/auth0/client.rb +8 -6
  40. data/lib/auth0/exception.rb +29 -23
  41. data/lib/auth0/mixins.rb +12 -10
  42. data/lib/auth0/mixins/httparty_proxy.rb +13 -10
  43. data/lib/auth0/mixins/initializer.rb +25 -27
  44. data/lib/auth0/version.rb +2 -2
  45. data/spec/integration/lib/auth0/api/v1/api_clients_spec.rb +2 -4
  46. data/spec/integration/lib/auth0/api/v1/api_users_spec.rb +25 -32
  47. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +14 -0
  48. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +61 -6
  49. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +68 -42
  50. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +71 -0
  51. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +69 -0
  52. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +83 -0
  53. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +16 -0
  54. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +37 -0
  55. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +33 -0
  56. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +88 -36
  57. data/spec/integration/lib/auth0/auth0_client_spec.rb +43 -35
  58. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +253 -47
  59. data/spec/lib/auth0/api/v1/clients_spec.rb +37 -38
  60. data/spec/lib/auth0/api/v1/connections_spec.rb +44 -38
  61. data/spec/lib/auth0/api/v1/logs_spec.rb +24 -24
  62. data/spec/lib/auth0/api/v1/rules_spec.rb +23 -22
  63. data/spec/lib/auth0/api/v1/users_spec.rb +153 -130
  64. data/spec/lib/auth0/api/v2/blacklists_spec.rb +12 -11
  65. data/spec/lib/auth0/api/v2/clients_spec.rb +38 -33
  66. data/spec/lib/auth0/api/v2/connections_spec.rb +59 -34
  67. data/spec/lib/auth0/api/v2/emails_spec.rb +47 -0
  68. data/spec/lib/auth0/api/v2/jobs_spec.rb +24 -10
  69. data/spec/lib/auth0/api/v2/rules_spec.rb +69 -0
  70. data/spec/lib/auth0/api/v2/stats_spec.rb +11 -11
  71. data/spec/lib/auth0/api/v2/tenants_spec.rb +25 -0
  72. data/spec/lib/auth0/api/v2/tickets_spec.rb +31 -0
  73. data/spec/lib/auth0/api/v2/users_spec.rb +101 -39
  74. data/spec/lib/auth0/client_spec.rb +46 -58
  75. data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +98 -69
  76. data/spec/lib/auth0/mixins/initializer_spec.rb +2 -2
  77. data/spec/spec_helper.rb +2 -2
  78. data/spec/spec_helper_full.rb +16 -15
  79. data/spec/spec_helper_unit.rb +5 -5
  80. data/spec/support/credentials.rb +9 -3
  81. data/spec/support/dummy_class.rb +7 -1
  82. data/spec/support/dummy_class_for_proxy.rb +2 -2
  83. data/spec/support/import_users.json +13 -0
  84. data/spec/support/stub_response.rb +1 -2
  85. metadata +78 -41
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Api::V1::Clients do
3
3
  before :all do
4
4
  dummy_instance = DummyClass.new
@@ -6,57 +6,56 @@ describe Auth0::Api::V1::Clients do
6
6
  @instance = dummy_instance
7
7
  end
8
8
 
9
- context ".clients" do
10
- it {expect(@instance).to respond_to(:clients)}
11
- it "is expected to send get request to /api/clients" do
12
- expect(@instance).to receive(:get).with("/api/clients")
13
- expect{@instance.clients}.not_to raise_error
9
+ context '.clients' do
10
+ it { expect(@instance).to respond_to(:clients) }
11
+ it 'is expected to send get request to /api/clients' do
12
+ expect(@instance).to receive(:get).with('/api/clients')
13
+ expect { @instance.clients }.not_to raise_error
14
14
  end
15
15
  end
16
16
 
17
- context ".create_client" do
18
- it {expect(@instance).to respond_to(:create_client)}
19
- it "is expected to send post request to /api/clients" do
20
- client_name = "ClientRandomName"
21
- callbacks = "Some absolutely random stuff here"
22
- expect(@instance).to receive(:post).with("/api/clients",{name: client_name, callbacks: callbacks})
23
- expect{@instance.create_client(client_name, callbacks)}.not_to raise_error
17
+ context '.create_client' do
18
+ it { expect(@instance).to respond_to(:create_client) }
19
+ it 'is expected to send post request to /api/clients' do
20
+ client_name = 'ClientRandomName'
21
+ callbacks = 'Some absolutely random stuff here'
22
+ expect(@instance).to receive(:post).with('/api/clients', name: client_name, callbacks: callbacks)
23
+ expect { @instance.create_client(client_name, callbacks) }.not_to raise_error
24
24
  end
25
25
  end
26
26
 
27
- context ".create_client" do
28
- it {expect(@instance).to respond_to(:create_client)}
29
- it "is expected to send post request to /api/clients" do
30
- client_name = "Some random name"
31
- callbacks = "Some random stuff"
32
- expect(@instance).to receive(:post).with("/api/clients",{name: client_name, callbacks: callbacks})
33
- expect{@instance.create_client(client_name, callbacks)}.not_to raise_error
27
+ context '.create_client' do
28
+ it { expect(@instance).to respond_to(:create_client) }
29
+ it 'is expected to send post request to /api/clients' do
30
+ client_name = 'Some random name'
31
+ callbacks = 'Some random stuff'
32
+ expect(@instance).to receive(:post).with('/api/clients', name: client_name, callbacks: callbacks)
33
+ expect { @instance.create_client(client_name, callbacks) }.not_to raise_error
34
34
  end
35
35
  end
36
36
 
37
- context ".update_client" do
38
- it {expect(@instance).to respond_to(:update_client)}
39
- it "is expected to perform put to /api/clients/#client_id" do
40
- client_name = "Some random name"
41
- callbacks = "Some random stuff"
42
- expect(@instance).to receive(:put).with("/api/clients/client_id",{name: client_name, callbacks: callbacks})
43
- expect{@instance.update_client(client_name, callbacks, "client_id")}.not_to raise_error
37
+ context '.update_client' do
38
+ it { expect(@instance).to respond_to(:update_client) }
39
+ it 'is expected to perform put to /api/clients/#client_id' do
40
+ client_name = 'Some random name'
41
+ callbacks = 'Some random stuff'
42
+ expect(@instance).to receive(:put).with('/api/clients/client_id', name: client_name, callbacks: callbacks)
43
+ expect { @instance.update_client(client_name, callbacks, 'client_id') }.not_to raise_error
44
44
  end
45
45
 
46
- it "is expected to make warn on deprecated endpoint" do
47
- expect(@instance).to receive(:warn).with("This endpoint has been deprecated in favor of PATCH.")
48
- @instance.update_client("test")
46
+ it 'is expected to make warn on deprecated endpoint' do
47
+ expect(@instance).to receive(:warn).with('This endpoint has been deprecated in favor of PATCH.')
48
+ @instance.update_client('test')
49
49
  end
50
50
  end
51
51
 
52
- context ".patch_client" do
53
- it {expect(@instance).to respond_to(:patch_client)}
54
- it "is expected to perform patch to /api/clients/#client_id" do
55
- client_name = "Some random name"
56
- callbacks = "Some random stuff"
57
- expect(@instance).to receive(:patch).with("/api/clients/client_id",{name: client_name, callbacks: callbacks})
58
- expect{@instance.patch_client(client_name, callbacks, "client_id")}.not_to raise_error
52
+ context '.patch_client' do
53
+ it { expect(@instance).to respond_to(:patch_client) }
54
+ it 'is expected to perform patch to /api/clients/#client_id' do
55
+ client_name = 'Some random name'
56
+ callbacks = 'Some random stuff'
57
+ expect(@instance).to receive(:patch).with('/api/clients/client_id', name: client_name, callbacks: callbacks)
58
+ expect { @instance.patch_client(client_name, callbacks, 'client_id') }.not_to raise_error
59
59
  end
60
60
  end
61
-
62
61
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Api::V1::Connections do
3
3
  before :all do
4
4
  dummy_instance = DummyClass.new
@@ -7,56 +7,62 @@ describe Auth0::Api::V1::Connections do
7
7
  @instance = dummy_instance
8
8
  end
9
9
 
10
- context ".connections" do
11
- it {expect(@instance).to respond_to(:connections)}
12
- it {expect(@instance).to respond_to(:get_connections)}
13
- it "is expected to send get request to /api/connections" do
14
- expect(@instance).to receive(:get).with("/api/connections")
15
- expect{@instance.connections}.not_to raise_error
10
+ context '.connections' do
11
+ it { expect(@instance).to respond_to(:connections) }
12
+ it { expect(@instance).to respond_to(:get_connections) }
13
+ it 'is expected to send get request to /api/connections' do
14
+ expect(@instance).to receive(:get).with('/api/connections')
15
+ expect { @instance.connections }.not_to raise_error
16
16
  end
17
17
  end
18
18
 
19
- context ".connection" do
20
- it {expect(@instance).to respond_to(:connection)}
21
- it "it is expected to send get request to /api/connections/RandomConnectionName" do
22
- expect(@instance).to receive(:get).with("/api/connections/RandomConnectionName")
23
- expect{@instance.connection("RandomConnectionName")}.not_to raise_error
19
+ context '.connection' do
20
+ it { expect(@instance).to respond_to(:connection) }
21
+ it 'it is expected to send get request to /api/connections/RandomConnectionName' do
22
+ expect(@instance).to receive(:get).with('/api/connections/RandomConnectionName')
23
+ expect { @instance.connection('RandomConnectionName') }.not_to raise_error
24
24
  end
25
25
  end
26
26
 
27
- context ".delete_connection" do
28
- it {expect(@instance).to respond_to(:delete_connection)}
29
- it "it is expected to send delete request to /api/connections/RandomConnectionName" do
30
- expect(@instance).to receive(:delete).with("/api/connections/RandomConnectionName")
31
- expect{@instance.delete_connection("RandomConnectionName")}.not_to raise_error
27
+ context '.delete_connection' do
28
+ it { expect(@instance).to respond_to(:delete_connection) }
29
+ it 'it is expected to send delete request to /api/connections/RandomConnectionName' do
30
+ expect(@instance).to receive(:delete).with('/api/connections/RandomConnectionName')
31
+ expect { @instance.delete_connection('RandomConnectionName') }.not_to raise_error
32
32
  end
33
33
  end
34
34
 
35
- context ".create_connection" do
36
- it {expect(@instance).to respond_to(:create_connection)}
37
- it "is expected to send post to /api/connections" do
38
- params= { name: "Some Test name",
39
- strategy: "Unpredictable",
40
- options: {
41
- tenant_domain: "google.com",
42
- domain_aliases: "test.google.com,auth0.com"
43
- }
35
+ context '.create_connection' do
36
+ it { expect(@instance).to respond_to(:create_connection) }
37
+ it 'is expected to send post to /api/connections' do
38
+ params = { name: 'Some Test name',
39
+ strategy: 'Unpredictable',
40
+ options: {
41
+ tenant_domain: 'google.com',
42
+ domain_aliases: 'test.google.com,auth0.com'
43
+ }
44
44
  }
45
- expect(@instance).to receive(:post).with("/api/connections",params)
46
- expect{@instance.create_connection("Some Test name", "Unpredictable", "google.com", "test.google.com,auth0.com")}.not_to raise_error
45
+ expect(@instance).to receive(:post).with('/api/connections', params)
46
+ expect do
47
+ @instance.create_connection(
48
+ 'Some Test name',
49
+ 'Unpredictable',
50
+ 'google.com',
51
+ 'test.google.com,auth0.com'
52
+ )
53
+ end.not_to raise_error
47
54
  end
48
55
  end
49
- context ".update_connection" do
50
- it {expect(@instance).to respond_to(:update_connection)}
51
- it "is expected to send put to /api/connections/TestName" do
52
- params= { status: false,
53
- options: {
54
- tenant_domain: "google.com",
55
- }
56
+ context '.update_connection' do
57
+ it { expect(@instance).to respond_to(:update_connection) }
58
+ it 'is expected to send put to /api/connections/TestName' do
59
+ params = { status: false,
60
+ options: {
61
+ tenant_domain: 'google.com'
62
+ }
56
63
  }
57
- expect(@instance).to receive(:put).with("/api/connections/TestName",params)
58
- expect{@instance.update_connection("TestName", "google.com", false)}.not_to raise_error
64
+ expect(@instance).to receive(:put).with('/api/connections/TestName', params)
65
+ expect { @instance.update_connection('TestName', 'google.com', false) }.not_to raise_error
59
66
  end
60
67
  end
61
-
62
68
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Api::V1::Logs do
3
3
  before :all do
4
4
  dummy_instance = DummyClass.new
@@ -7,40 +7,40 @@ describe Auth0::Api::V1::Logs do
7
7
  @instance = dummy_instance
8
8
  end
9
9
 
10
- context ".logs or .search_logs" do
11
- it {expect(@instance).to respond_to(:logs)}
12
- it {expect(@instance).to respond_to(:search_logs)}
13
- it "should call path with all provided params per_page" do
14
- expect(@instance).to receive(:get).with("/api/logs?per_page=500")
15
- expect{@instance.logs("per_page" => 500)}.not_to raise_error
10
+ context '.logs or .search_logs' do
11
+ it { expect(@instance).to respond_to(:logs) }
12
+ it { expect(@instance).to respond_to(:search_logs) }
13
+ it 'should call path with all provided params per_page' do
14
+ expect(@instance).to receive(:get).with('/api/logs?per_page=500')
15
+ expect { @instance.logs('per_page' => 500) }.not_to raise_error
16
16
  end
17
- it "should call path with all provided params per_page, page" do
18
- expect(@instance).to receive(:get).with("/api/logs?per_page=500&page=3")
19
- expect{@instance.logs("per_page" => 500, page: 3)}.not_to raise_error
17
+ it 'should call path with all provided params per_page, page' do
18
+ expect(@instance).to receive(:get).with('/api/logs?per_page=500&page=3')
19
+ expect { @instance.logs('per_page' => 500, page: 3) }.not_to raise_error
20
20
  end
21
21
 
22
- it "should raise warn if any garbage params are passed" do
23
- error_message = "random_stuff is not in acceptable params list: [:take, :from, :search_criteria, :page, :per_page, :sort, :fields, :exclude_fields]"
22
+ it 'should raise warn if any garbage params are passed' do
23
+ error_message = 'random_stuff is not in acceptable params list: '\
24
+ '[:take, :from, :search_criteria, :page, :per_page, :sort, :fields, '\
25
+ ':exclude_fields]'
24
26
  expect(@instance).to receive(:warn).with(error_message)
25
- @instance.logs("per_page" => 500, page: 3, random_stuff:7 )
27
+ @instance.logs('per_page' => 500, page: 3, random_stuff: 7)
26
28
  end
27
29
  end
28
30
 
29
- context ".log" do
30
- it {expect(@instance).to respond_to :log}
31
+ context '.log' do
32
+ it { expect(@instance).to respond_to :log }
31
33
  it "is expected to get '/api/logs/te st'" do
32
- expect(@instance).to receive(:get).with("/api/logs/te st")
33
- expect{@instance.log("te st")}.not_to raise_error
34
+ expect(@instance).to receive(:get).with('/api/logs/te st')
35
+ expect { @instance.log('te st') }.not_to raise_error
34
36
  end
35
37
  end
36
38
 
37
- context ".user_logs" do
38
- it {expect(@instance).to respond_to(:user_logs)}
39
- it "is expected to get /api/users/#user_id/logs" do
40
- expect(@instance).to receive(:get).with("/api/users/auth0|test test/logs?page=0&per_page=50")
41
- expect{@instance.user_logs("auth0|test test")}.not_to raise_error
39
+ context '.user_logs' do
40
+ it { expect(@instance).to respond_to(:user_logs) }
41
+ it 'is expected to get /api/users/#user_id/logs' do
42
+ expect(@instance).to receive(:get).with('/api/users/auth0|test test/logs?page=0&per_page=50')
43
+ expect { @instance.user_logs('auth0|test test') }.not_to raise_error
42
44
  end
43
45
  end
44
-
45
-
46
46
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
  describe Auth0::Api::V1::Rules do
3
3
  before :all do
4
4
  dummy_instance = DummyClass.new
@@ -7,34 +7,35 @@ describe Auth0::Api::V1::Rules do
7
7
  @instance = dummy_instance
8
8
  end
9
9
 
10
- context ".rules" do
11
- it {expect(@instance).to respond_to(:rules)}
12
- it "is expected to call get /api/rules" do
13
- expect(@instance).to receive(:get).with("/api/rules")
14
- expect{@instance.rules}.not_to raise_error
10
+ context '.rules' do
11
+ it { expect(@instance).to respond_to(:rules) }
12
+ it 'is expected to call get /api/rules' do
13
+ expect(@instance).to receive(:get).with('/api/rules')
14
+ expect { @instance.rules }.not_to raise_error
15
15
  end
16
16
  end
17
17
 
18
- context ".create_rule" do
19
- it {expect(@instance).to respond_to(:create_rule)}
20
- it "is expected to call post /api/rules" do
21
- expect(@instance).to receive(:post).with("/api/rules", {name:"test",script:"script",order:"order",status:"status"})
22
- expect{@instance.create_rule("test", "script", "order", "status")}.not_to raise_error
18
+ context '.create_rule' do
19
+ it { expect(@instance).to respond_to(:create_rule) }
20
+ it 'is expected to call post /api/rules' do
21
+ expect(@instance).to receive(:post).with(
22
+ '/api/rules',
23
+ name: 'test', script: 'script', order: 'order', status: 'status')
24
+ expect { @instance.create_rule('test', 'script', 'order', 'status') }.not_to raise_error
23
25
  end
24
26
  end
25
- context ".update_rule" do
26
- it {expect(@instance).to respond_to(:update_rule)}
27
- it "is expected to call put /api/rules/test" do
28
- expect(@instance).to receive(:put).with("/api/rules/test", {script:"script",order:"order",status:"status"})
29
- expect{@instance.update_rule("test", "script", "order", "status")}.not_to raise_error
27
+ context '.update_rule' do
28
+ it { expect(@instance).to respond_to(:update_rule) }
29
+ it 'is expected to call put /api/rules/test' do
30
+ expect(@instance).to receive(:put).with('/api/rules/test', script: 'script', order: 'order', status: 'status')
31
+ expect { @instance.update_rule('test', 'script', 'order', 'status') }.not_to raise_error
30
32
  end
31
33
  end
32
- context ".delete_rule" do
33
- it {expect(@instance).to respond_to(:delete_rule)}
34
- it "is expected to call delete /api/rules/test" do
35
- expect(@instance).to receive(:delete).with("/api/rules/test")
36
- expect{@instance.delete_rule("test")}.not_to raise_error
34
+ context '.delete_rule' do
35
+ it { expect(@instance).to respond_to(:delete_rule) }
36
+ it 'is expected to call delete /api/rules/test' do
37
+ expect(@instance).to receive(:delete).with('/api/rules/test')
38
+ expect { @instance.delete_rule('test') }.not_to raise_error
37
39
  end
38
40
  end
39
-
40
41
  end
@@ -1,5 +1,5 @@
1
- require "spec_helper"
2
- require "securerandom"
1
+ require 'spec_helper'
2
+ require 'securerandom'
3
3
 
4
4
  describe Auth0::Api::V1::Users do
5
5
  before :all do
@@ -8,210 +8,233 @@ describe Auth0::Api::V1::Users do
8
8
  @instance = dummy_instance
9
9
  end
10
10
 
11
- context ".users" do
12
- it {expect(@instance).to respond_to(:users)}
13
- it {expect(@instance).to respond_to(:users_search)}
14
- it "is expected to call /api/users when search is nill" do
15
- expect(@instance).to receive(:get).with("/api/users")
16
- expect{@instance.users}.not_to raise_error
11
+ context '.users' do
12
+ it { expect(@instance).to respond_to(:users) }
13
+ it { expect(@instance).to respond_to(:users_search) }
14
+ it 'is expected to call /api/users when search is nill' do
15
+ expect(@instance).to receive(:get).with('/api/users')
16
+ expect { @instance.users }.not_to raise_error
17
17
  end
18
18
 
19
- it "is expected to call /api/users?search=search_criteria when search is search_criteria" do
20
- expect(@instance).to receive(:get).with("/api/users?search=search_criteria")
21
- expect{@instance.users("search_criteria")}.not_to raise_error
19
+ it 'is expected to call /api/users?search=search_criteria when search is search_criteria' do
20
+ expect(@instance).to receive(:get).with('/api/users?search=search_criteria')
21
+ expect { @instance.users('search_criteria') }.not_to raise_error
22
22
  end
23
23
  end
24
24
 
25
- context ".user" do
26
- it {expect(@instance).to respond_to(:user)}
27
- it "is expected to call get request to /api/users/USER_ID" do
28
- expect(@instance).to receive(:get).with("/api/users/USER_ID")
29
- expect{@instance.user("USER_ID")}.not_to raise_error
25
+ context '.user' do
26
+ it { expect(@instance).to respond_to(:user) }
27
+ it 'is expected to call get request to /api/users/USER_ID' do
28
+ expect(@instance).to receive(:get).with('/api/users/USER_ID')
29
+ expect { @instance.user('USER_ID') }.not_to raise_error
30
30
  end
31
31
  end
32
32
 
33
- context ".user_devices" do
34
- it {expect(@instance).to respond_to(:user_devices)}
35
- it "is expected to call /api/users when search is nill" do
36
- expect(@instance).to receive(:get).with("/api/users/USER_ID/devices")
37
- expect{@instance.user_devices("USER_ID")}.not_to raise_error
33
+ context '.user_devices' do
34
+ it { expect(@instance).to respond_to(:user_devices) }
35
+ it 'is expected to call /api/users when search is nill' do
36
+ expect(@instance).to receive(:get).with('/api/users/USER_ID/devices')
37
+ expect { @instance.user_devices('USER_ID') }.not_to raise_error
38
38
  end
39
39
  end
40
40
 
41
- context ".connection_users" do
42
- it {expect(@instance).to respond_to(:connection_users)}
43
- it {expect(@instance).to respond_to(:search_connection_users)}
44
- it "is expected to call /api/connections/CONNECTION_ID/users/ when search is nill" do
45
- expect(@instance).to receive(:get).with("/api/connections/CONNECTION_ID/users")
46
- expect{@instance.connection_users("CONNECTION_ID")}.not_to raise_error
41
+ context '.connection_users' do
42
+ it { expect(@instance).to respond_to(:connection_users) }
43
+ it { expect(@instance).to respond_to(:search_connection_users) }
44
+ it 'is expected to call /api/connections/CONNECTION_ID/users/ when search is nill' do
45
+ expect(@instance).to receive(:get).with('/api/connections/CONNECTION_ID/users')
46
+ expect { @instance.connection_users('CONNECTION_ID') }.not_to raise_error
47
47
  end
48
48
 
49
- it "is expected to call /api/connections/CONNECTION_ID/users?search=search_criteria when search is search_criteria" do
50
- expect(@instance).to receive(:get).with("/api/connections/CONNECTION_ID/users?search=search_criteria")
51
- expect{@instance.connection_users("CONNECTION_ID", "search_criteria")}.not_to raise_error
49
+ it 'is expected to call
50
+ /api/connections/CONNECTION_ID/users?search=search_criteria when search is search_criteria' do
51
+ expect(@instance).to receive(:get).with('/api/connections/CONNECTION_ID/users?search=search_criteria')
52
+ expect { @instance.connection_users('CONNECTION_ID', 'search_criteria') }.not_to raise_error
52
53
  end
53
54
  end
54
55
 
55
- context ".enterpriseconnections_users" do
56
- it{expect(@instance).to respond_to(:enterpriseconnections_users)}
57
- it "is expected to call get to /api/enterpriseconnections/users" do
58
- expect(@instance).to receive(:get).with("/api/enterpriseconnections/users?search=arr a&per_page=11")
59
- @instance.enterpriseconnections_users "arr a", 11
56
+ context '.enterpriseconnections_users' do
57
+ it { expect(@instance).to respond_to(:enterpriseconnections_users) }
58
+ it 'is expected to call get to /api/enterpriseconnections/users' do
59
+ expect(@instance).to receive(:get).with('/api/enterpriseconnections/users?search=arr a&per_page=11')
60
+ @instance.enterpriseconnections_users 'arr a', 11
60
61
  end
61
62
 
62
- it "is expected to call get to /api/enterpriseconnections/users?search=dfasdf&per_page=500" do
63
- expect(@instance).to receive(:get).with("/api/enterpriseconnections/users?search=arr a&per_page=500")
64
- @instance.enterpriseconnections_users "arr a"
63
+ it 'is expected to call get to /api/enterpriseconnections/users?search=dfasdf&per_page=500' do
64
+ expect(@instance).to receive(:get).with('/api/enterpriseconnections/users?search=arr a&per_page=500')
65
+ @instance.enterpriseconnections_users 'arr a'
65
66
  end
66
67
  end
67
68
 
68
- context ".socialconnections_users" do
69
- it{expect(@instance).to respond_to(:socialconnections_users)}
70
- it "is expected to call get to /api/socialconnections/users" do
71
- expect(@instance).to receive(:get).with("/api/socialconnections/users?search=arr a&per_page=11")
72
- @instance.socialconnections_users "arr a", 11
69
+ context '.socialconnections_users' do
70
+ it { expect(@instance).to respond_to(:socialconnections_users) }
71
+ it 'is expected to call get to /api/socialconnections/users' do
72
+ expect(@instance).to receive(:get).with('/api/socialconnections/users?search=arr a&per_page=11')
73
+ @instance.socialconnections_users 'arr a', 11
73
74
  end
74
- it "is expected to call get to /api/socialconnections/users" do
75
- expect(@instance).to receive(:get).with("/api/socialconnections/users?search=arr a&per_page=500")
76
- @instance.socialconnections_users "arr a"
75
+ it 'is expected to call get to /api/socialconnections/users' do
76
+ expect(@instance).to receive(:get).with('/api/socialconnections/users?search=arr a&per_page=500')
77
+ @instance.socialconnections_users 'arr a'
77
78
  end
78
- it "is expected to call get to /api/socialconnections/users" do
79
- expect(@instance).to receive(:get).with("/api/socialconnections/users?search=&per_page=500")
79
+ it 'is expected to call get to /api/socialconnections/users' do
80
+ expect(@instance).to receive(:get).with('/api/socialconnections/users?search=&per_page=500')
80
81
  @instance.socialconnections_users
81
82
  end
82
83
  end
83
84
 
84
- context ".client_users" do
85
- it {expect(@instance).to respond_to(:client_users)}
86
- it "is expected to call /api/client/test_client_id/users through get" do
87
- expect(@instance).to receive(:get).with("/api/clients/test_client_id/users")
88
- @instance.client_users("test_client_id")
85
+ context '.client_users' do
86
+ it { expect(@instance).to respond_to(:client_users) }
87
+ it 'is expected to call /api/client/test_client_id/users through get' do
88
+ expect(@instance).to receive(:get).with('/api/clients/test_client_id/users')
89
+ @instance.client_users('test_client_id')
89
90
  end
90
- it "is expected to call /api/client//users if no client_id passed" do
91
- expect(@instance).to receive(:get).with("/api/clients//users")
92
- expect{@instance.client_users()}.not_to raise_error
91
+ it 'is expected to call /api/client//users if no client_id passed' do
92
+ expect(@instance).to receive(:get).with('/api/clients//users')
93
+ expect { @instance.client_users }.not_to raise_error
93
94
  end
94
95
  end
95
96
 
96
- context ".create_user" do
97
- it {expect(@instance).to respond_to(:create_user)}
98
- it "is expected to call post to /api/users" do
99
- expect(@instance).to receive(:post).with("/api/users", {email: "test@test.com", password: "password", connection: "conn"})
100
- @instance.create_user("test@test.com", "password", "conn")
97
+ context '.create_user' do
98
+ it { expect(@instance).to respond_to(:create_user) }
99
+ it 'is expected to call post to /api/users' do
100
+ expect(@instance).to receive(:post).with(
101
+ '/api/users',
102
+ email: 'test@test.com',
103
+ password: 'password',
104
+ connection: 'conn')
105
+ @instance.create_user('test@test.com', 'password', 'conn')
101
106
  end
102
107
  end
103
108
 
104
- context ".send_verification_email" do
105
- it {expect(@instance).to respond_to(:send_verification_email)}
106
- it "is expected to call post to /api/users/test/send_verification_email" do
107
- expect(@instance).to receive(:post).with("/api/users/test/send_verification_email")
108
- @instance.send_verification_email("test")
109
+ context '.send_verification_email' do
110
+ it { expect(@instance).to respond_to(:send_verification_email) }
111
+ it 'is expected to call post to /api/users/test/send_verification_email' do
112
+ expect(@instance).to receive(:post).with('/api/users/test/send_verification_email')
113
+ @instance.send_verification_email('test')
109
114
  end
110
115
  end
111
116
 
112
- context ".change_password_ticket" do
113
- it {expect(@instance).to respond_to(:change_password_ticket)}
114
- it "is expected to call post to /api/users/USERID/change_password_ticket" do
117
+ context '.change_password_ticket' do
118
+ it { expect(@instance).to respond_to(:change_password_ticket) }
119
+ it 'is expected to call post to /api/users/USERID/change_password_ticket' do
115
120
  password = SecureRandom.hex
116
- expect(@instance).to receive(:post).with("/api/users/USERID/change_password_ticket", { "newPassword" => password, "resultUrl" => nil })
117
- @instance.change_password_ticket "USERID", password
121
+ expect(@instance).to receive(:post).with(
122
+ '/api/users/USERID/change_password_ticket',
123
+ 'newPassword' => password, 'resultUrl' => nil)
124
+ @instance.change_password_ticket 'USERID', password
118
125
  end
119
126
  end
120
127
 
121
- context ".verification_ticket" do
122
- it {expect(@instance).to respond_to(:verification_ticket)}
123
- it "is expected to call post to /api/users/userId/verification_ticket if resulturl is set" do
124
- expect(@instance).to receive(:post).with("/api/users/auth0|tdasfasdfasdfa/verification_ticket", {"resultUrl" => "google.com"})
125
- @instance.verification_ticket("auth0|tdasfasdfasdfa","google.com")
128
+ context '.verification_ticket' do
129
+ it { expect(@instance).to respond_to(:verification_ticket) }
130
+ it 'is expected to call post to /api/users/userId/verification_ticket if resulturl is set' do
131
+ expect(@instance).to receive(:post).with(
132
+ '/api/users/auth0|tdasfasdfasdfa/verification_ticket',
133
+ 'resultUrl' => 'google.com')
134
+ @instance.verification_ticket('auth0|tdasfasdfasdfa', 'google.com')
126
135
  end
127
- it "is expected to call post to /api/users/userId/verification_ticket if result url is empty" do
128
- expect(@instance).to receive(:post).with("/api/users/auth0|tdasfasdfasdfa/verification_ticket", {"resultUrl" => nil})
129
- @instance.verification_ticket("auth0|tdasfasdfasdfa")
136
+ it 'is expected to call post to /api/users/userId/verification_ticket
137
+ if result url is empty' do
138
+ expect(@instance).to receive(:post).with(
139
+ '/api/users/auth0|tdasfasdfasdfa/verification_ticket',
140
+ 'resultUrl' => nil)
141
+ @instance.verification_ticket('auth0|tdasfasdfasdfa')
130
142
  end
131
143
  end
132
144
 
133
- context ".create_public_key" do
134
- it {expect(@instance).to respond_to(:create_public_key)}
135
- it "is expected to call post to /api/users/userId/public_key" do
136
- expect(@instance).to receive(:post).with("/api/users/auth0|tdasfasdfasdfa/public_key", {device: "device22", public_key: "SuperSecurePK"})
137
- @instance.create_public_key("auth0|tdasfasdfasdfa","device22", "SuperSecurePK")
145
+ context '.create_public_key' do
146
+ it { expect(@instance).to respond_to(:create_public_key) }
147
+ it 'is expected to call post to /api/users/userId/public_key' do
148
+ expect(@instance).to receive(:post).with(
149
+ '/api/users/auth0|tdasfasdfasdfa/public_key',
150
+ device: 'device22', public_key: 'SuperSecurePK')
151
+ @instance.create_public_key('auth0|tdasfasdfasdfa', 'device22', 'SuperSecurePK')
138
152
  end
139
153
  end
140
154
 
141
- context ".update_user_email" do
142
- it {expect(@instance).to respond_to(:update_user_email)}
143
- it "is expected to call put to /api/users/auth0|tdasfasdfasdfa/email" do
144
- expect(@instance).to receive(:put).with("/api/users/auth0|tdasfasdfasdfa/email", {email:"email", verify: true})
145
- @instance.update_user_email("auth0|tdasfasdfasdfa", "email")
155
+ context '.update_user_email' do
156
+ it { expect(@instance).to respond_to(:update_user_email) }
157
+ it 'is expected to call put to /api/users/auth0|tdasfasdfasdfa/email' do
158
+ expect(@instance).to receive(:put).with('/api/users/auth0|tdasfasdfasdfa/email', email: 'email', verify: true)
159
+ @instance.update_user_email('auth0|tdasfasdfasdfa', 'email')
146
160
  end
147
161
  end
148
162
 
149
- context ".update_user_metadata" do
150
- it {expect(@instance).to respond_to :update_user_metadata}
151
- it "is expected to call put to /api/users/userId/metadata" do
152
- expect(@instance).to receive(:put).with("/api/users/userId/metadata", {supersecret_users_data: "3"})
153
- @instance.update_user_metadata "userId", {supersecret_users_data: "3"}
163
+ context '.update_user_metadata' do
164
+ it { expect(@instance).to respond_to :update_user_metadata }
165
+ it 'is expected to call put to /api/users/userId/metadata' do
166
+ expect(@instance).to receive(:put).with('/api/users/userId/metadata', supersecret_users_data: '3')
167
+ @instance.update_user_metadata 'userId', supersecret_users_data: '3'
154
168
  end
155
169
  end
156
170
 
157
- context ".update_user_password" do
158
- it {expect(@instance).to respond_to(:update_user_password)}
159
- it "is expected to call put to /api/users/auth0|tdasfasdfasdfa/password" do
160
- expect(@instance).to receive(:put).with("/api/users/auth0|tdasfasdfasdfa/password", {password:"password", verify: true})
161
- @instance.update_user_password("auth0|tdasfasdfasdfa", "password")
171
+ context '.update_user_password' do
172
+ it { expect(@instance).to respond_to(:update_user_password) }
173
+ it 'is expected to call put to /api/users/auth0|tdasfasdfasdfa/password' do
174
+ expect(@instance).to receive(:put).with(
175
+ '/api/users/auth0|tdasfasdfasdfa/password',
176
+ password: 'password',
177
+ verify: true)
178
+ @instance.update_user_password('auth0|tdasfasdfasdfa', 'password')
162
179
  end
163
180
  end
164
181
 
165
- context ".update_user_password_using_email" do
166
- it {expect(@instance).to respond_to(:update_user_password_using_email)}
167
- it "is expected to call put to /api/users/email@email.com/password" do
168
- expect(@instance).to receive(:put).with("/api/users/email@email.com/password", {email: "email@email.com", password:"password", connection:"Con", verify: true})
169
- @instance.update_user_password_using_email("email@email.com", "password", "Con")
182
+ context '.update_user_password_using_email' do
183
+ it { expect(@instance).to respond_to(:update_user_password_using_email) }
184
+ it 'is expected to call put to /api/users/email@email.com/password' do
185
+ expect(@instance).to receive(:put).with(
186
+ '/api/users/email@email.com/password',
187
+ email: 'email@email.com',
188
+ password: 'password',
189
+ connection: 'Con',
190
+ verify: true)
191
+ @instance.update_user_password_using_email(
192
+ 'email@email.com', 'password', 'Con')
170
193
  end
171
194
  end
172
195
 
173
- context ".patch_user_metadata" do
174
- it {expect(@instance).to respond_to :patch_user_metadata}
175
- it "is expected to call patch to /api/users/userId/metadata" do
176
- expect(@instance).to receive(:patch).with("/api/users/userId/metadata", {supersecret_users_data: "3"})
177
- @instance.patch_user_metadata "userId", {supersecret_users_data: "3"}
196
+ context '.patch_user_metadata' do
197
+ it { expect(@instance).to respond_to :patch_user_metadata }
198
+ it 'is expected to call patch to /api/users/userId/metadata' do
199
+ expect(@instance).to receive(:patch).with('/api/users/userId/metadata', supersecret_users_data: '3')
200
+ @instance.patch_user_metadata 'userId', supersecret_users_data: '3'
178
201
  end
179
202
  end
180
203
 
181
- context ".delete_users" do
182
- it {expect(@instance).to respond_to :delete_users}
183
- it "is expected to call delete to /api/users" do
184
- expect(@instance).to receive(:delete).with("/api/users/")
204
+ context '.delete_users' do
205
+ it { expect(@instance).to respond_to :delete_users }
206
+ it 'is expected to call delete to /api/users' do
207
+ expect(@instance).to receive(:delete).with('/api/users/')
185
208
  @instance.delete_users
186
209
  end
187
210
  end
188
211
 
189
- context ".delete_user" do
190
- it {expect(@instance).to respond_to(:delete_user)}
191
- it "is expected to call delete to /api/users/userId" do
192
- expect(@instance).to receive(:delete).with("/api/users/userId")
193
- @instance.delete_user("userId")
212
+ context '.delete_user' do
213
+ it { expect(@instance).to respond_to(:delete_user) }
214
+ it 'is expected to call delete to /api/users/userId' do
215
+ expect(@instance).to receive(:delete).with('/api/users/userId')
216
+ @instance.delete_user('userId')
194
217
  end
195
218
 
196
- it "is expected not to call delete to /api/users if user_id is blank" do
219
+ it 'is expected not to call delete to /api/users if user_id is blank' do
197
220
  expect(@instance).not_to receive(:delete)
198
- expect{@instance.delete_user("")}.to raise_exception(Auth0::MissingUserId)
221
+ expect { @instance.delete_user('') }.to raise_exception(Auth0::MissingUserId)
199
222
  end
200
223
  end
201
224
 
202
- context ".revoke_user_refresh_token" do
203
- it {expect(@instance).to respond_to(:revoke_user_refresh_token)}
204
- it "is expected to call delete to /api/users/user_id/refresh_tokens/refresh_token" do
205
- expect(@instance).to receive(:delete).with("/api/users/user_id/refresh_tokens/refresh_token")
206
- @instance.revoke_user_refresh_token("user_id", "refresh_token")
225
+ context '.revoke_user_refresh_token' do
226
+ it { expect(@instance).to respond_to(:revoke_user_refresh_token) }
227
+ it 'is expected to call delete to /api/users/user_id/refresh_tokens/refresh_token' do
228
+ expect(@instance).to receive(:delete).with('/api/users/user_id/refresh_tokens/refresh_token')
229
+ @instance.revoke_user_refresh_token('user_id', 'refresh_token')
207
230
  end
208
231
  end
209
232
 
210
- context ".revoke_user_device_public_key" do
211
- it {expect(@instance).to respond_to(:revoke_user_device_public_key)}
212
- it "is expected to call delete to /api/users/user_id/publickey?device=device" do
213
- expect(@instance).to receive(:delete).with("/api/users/user_id/publickey?device=device")
214
- @instance.revoke_user_device_public_key("user_id", "device")
233
+ context '.revoke_user_device_public_key' do
234
+ it { expect(@instance).to respond_to(:revoke_user_device_public_key) }
235
+ it 'is expected to call delete to /api/users/user_id/publickey?device=device' do
236
+ expect(@instance).to receive(:delete).with('/api/users/user_id/publickey?device=device')
237
+ @instance.revoke_user_device_public_key('user_id', 'device')
215
238
  end
216
239
  end
217
240
  end