auth0 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +5 -2
- data/.rspec +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +68 -0
- data/auth0.gemspec +11 -10
- data/doc/Auth0/AccessDenied.html +142 -0
- data/doc/Auth0/Api/AuthenticationEndpoints.html +592 -0
- data/doc/Auth0/Api/V1/Clients.html +440 -0
- data/doc/Auth0/Api/V1/Connections.html +506 -0
- data/doc/Auth0/Api/V1/Logs.html +366 -0
- data/doc/Auth0/Api/V1/Rules.html +439 -0
- data/doc/Auth0/Api/V1/Users.html +1617 -0
- data/doc/Auth0/Api/V1.html +188 -0
- data/doc/Auth0/Api/V2/Blacklists.html +268 -0
- data/doc/Auth0/Api/V2/Clients.html +477 -0
- data/doc/Auth0/Api/V2/Jobs.html +277 -0
- data/doc/Auth0/Api/V2/Router.html +109 -0
- data/doc/Auth0/Api/V2/Stats.html +268 -0
- data/doc/Auth0/Api/V2/Users.html +652 -0
- data/doc/Auth0/Api/V2.html +193 -0
- data/doc/Auth0/Api.html +128 -0
- data/doc/Auth0/BadRequest.html +142 -0
- data/doc/Auth0/Client.html +164 -0
- data/doc/Auth0/Exception.html +140 -0
- data/doc/Auth0/InvalidParameter.html +142 -0
- data/doc/Auth0/Mixins/HTTPartyProxy.html +121 -0
- data/doc/Auth0/Mixins/Initializer.html +312 -0
- data/doc/Auth0/Mixins.html +153 -0
- data/doc/Auth0/NotFound.html +143 -0
- data/doc/Auth0/ServerError.html +142 -0
- data/doc/Auth0/Unauthorized.html +143 -0
- data/doc/Auth0/Unsupported.html +142 -0
- data/doc/Auth0/UserIdIsBlank.html +143 -0
- data/doc/Auth0.html +153 -0
- data/doc/Auth0Client.html +163 -0
- data/doc/_index.html +418 -0
- data/doc/class_list.html +58 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +103 -0
- data/doc/file_list.html +60 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +103 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +181 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +435 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/auth0/api/authentication_endpoints.rb +71 -0
- data/lib/auth0/api/v1/clients.rb +48 -0
- data/lib/auth0/api/v1/connections.rb +51 -0
- data/lib/auth0/api/v1/logs.rb +41 -0
- data/lib/auth0/api/v1/rules.rb +44 -0
- data/lib/auth0/api/v1/users.rb +163 -0
- data/lib/auth0/api/v1.rb +19 -0
- data/lib/auth0/api/v2/blacklists.rb +24 -0
- data/lib/auth0/api/v2/clients.rb +41 -0
- data/lib/auth0/api/v2/jobs.rb +20 -0
- data/lib/auth0/api/v2/stats.rb +24 -0
- data/lib/auth0/api/v2/users.rb +67 -0
- data/lib/auth0/api/v2.rb +17 -0
- data/lib/auth0/client.rb +5 -48
- data/lib/auth0/exception.rb +22 -0
- data/lib/auth0/mixins/httparty_proxy.rb +35 -0
- data/lib/auth0/mixins/initializer.rb +34 -0
- data/lib/auth0/mixins.rb +12 -0
- data/lib/auth0/version.rb +3 -2
- data/lib/auth0.rb +6 -1
- data/lib/auth0_client.rb +3 -0
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +56 -0
- data/spec/lib/auth0/api/v1/clients_spec.rb +62 -0
- data/spec/lib/auth0/api/v1/connections_spec.rb +62 -0
- data/spec/lib/auth0/api/v1/logs_spec.rb +46 -0
- data/spec/lib/auth0/api/v1/rules_spec.rb +40 -0
- data/spec/lib/auth0/api/v1/users_spec.rb +217 -0
- data/spec/lib/auth0/api/v2/blacklists_spec.rb +24 -0
- data/spec/lib/auth0/api/v2/clients_spec.rb +54 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +21 -0
- data/spec/lib/auth0/api/v2/stats_spec.rb +22 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +72 -0
- data/spec/lib/auth0/client_spec.rb +47 -0
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +119 -0
- data/spec/lib/auth0_client_spec.rb +8 -0
- data/spec/spec_helper.rb +8 -7
- data/spec/support/dummy_class.rb +7 -0
- data/spec/support/dummy_class_for_proxy.rb +4 -0
- data/spec/support/stub_response.rb +2 -0
- metadata +159 -28
- data/lib/omniauth/strategies/auth0.rb +0 -62
- data/spec/omniauth/strategies/auth0_spec.rb +0 -149
data/lib/auth0/mixins.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'uri'
|
3
|
+
require "auth0/mixins/httparty_proxy"
|
4
|
+
require "auth0/mixins/initializer"
|
5
|
+
require "auth0/api/authentication_endpoints"
|
6
|
+
require "auth0/api/v1"
|
7
|
+
require "auth0/api/v2"
|
8
|
+
# Collecting dependencies here
|
9
|
+
module Auth0::Mixins
|
10
|
+
include Auth0::Mixins::HTTPartyProxy
|
11
|
+
include Auth0::Mixins::Initializer
|
12
|
+
end
|
data/lib/auth0/version.rb
CHANGED
data/lib/auth0.rb
CHANGED
data/lib/auth0_client.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::AuthenticationEndpoints do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::AuthenticationEndpoints)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context ".obtain_access_token" do
|
10
|
+
it {expect(@instance).to respond_to(:obtain_access_token)}
|
11
|
+
it "is expected to make post request to '/oauth/token'" do
|
12
|
+
allow(@instance).to receive(:post).with("/oauth/token", {client_id: nil, client_secret: nil, grant_type: 'client_credentials'}).
|
13
|
+
and_return({"access_token" => "AccessToken"})
|
14
|
+
expect(@instance).to receive(:post).with("/oauth/token", {client_id: nil, client_secret: nil, grant_type: 'client_credentials'})
|
15
|
+
expect(@instance.obtain_access_token).to eql "AccessToken"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context ".delegation" do
|
20
|
+
it {expect(@instance).to respond_to(:delegation)}
|
21
|
+
it "is expected to make post request to '/delegation'" do
|
22
|
+
expect(@instance).to receive(:post).with("/delegation",{:client_id=>nil, :grant_type=>"urn:ietf:params:oauth:grant-type:jwt-bearer", :id_token=>"token", :target=>"target", :scope=>""})
|
23
|
+
@instance.delegation("token", "target", "")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context ".login" do
|
28
|
+
it {expect(@instance).to respond_to(:signup)}
|
29
|
+
it "is expected to make post to /oauth/ro" do
|
30
|
+
expect(@instance).to receive(:post).with("/oauth/ro", {client_id: nil, username:"test@test.com", password: "password", connection: "Username-Password-Authentication", scope: "openid", grand_type: "password", id_token: nil})
|
31
|
+
@instance.login("test@test.com", "password")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context ".signup" do
|
35
|
+
it {expect(@instance).to respond_to(:signup)}
|
36
|
+
it "is expected to make post to /dbconnections/signup" do
|
37
|
+
expect(@instance).to receive(:post).with("/dbconnections/signup", {client_id: nil, email: "test@test.com", password: "password", connection: "User"})
|
38
|
+
@instance.signup("test@test.com", "password", "User")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
context ".change_password" do
|
42
|
+
it {expect(@instance).to respond_to(:change_password)}
|
43
|
+
it "is expected to make post to /dbconnections/change_password" do
|
44
|
+
expect(@instance).to receive(:post).with("/dbconnections/change_password", {client_id: nil, email: "test@test.com", password: "password", connection: "User"})
|
45
|
+
@instance.change_password("test@test.com", "password", "User")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context ".token_info" do
|
50
|
+
it {expect(@instance).to respond_to(:token_info)}
|
51
|
+
it "is expected to make post to /tokeinfo" do
|
52
|
+
expect(@instance).to receive(:post).with("/tokeninfo", {id_token: "SomerandomToken"})
|
53
|
+
@instance.token_info("SomerandomToken")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V1::Clients do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V1::Clients)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
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
|
14
|
+
end
|
15
|
+
end
|
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
|
24
|
+
end
|
25
|
+
end
|
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
|
34
|
+
end
|
35
|
+
end
|
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
|
44
|
+
end
|
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 PUT.")
|
48
|
+
@instance.update_client("test")
|
49
|
+
end
|
50
|
+
end
|
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
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V1::Connections do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V1::Connections)
|
6
|
+
dummy_instance.extend(Auth0::Mixins::Initializer)
|
7
|
+
@instance = dummy_instance
|
8
|
+
end
|
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
|
16
|
+
end
|
17
|
+
end
|
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
|
24
|
+
end
|
25
|
+
end
|
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
|
32
|
+
end
|
33
|
+
end
|
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
|
+
}
|
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
|
47
|
+
end
|
48
|
+
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
|
+
}
|
57
|
+
expect(@instance).to receive(:put).with("/api/connections/TestName",params)
|
58
|
+
expect{@instance.update_connection("TestName", "google.com", false)}.not_to raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V1::Logs do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V1::Logs)
|
6
|
+
dummy_instance.extend(Auth0::Mixins::Initializer)
|
7
|
+
@instance = dummy_instance
|
8
|
+
end
|
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
|
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
|
20
|
+
end
|
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]"
|
24
|
+
expect(@instance).to receive(:warn).with(error_message)
|
25
|
+
@instance.logs("per_page" => 500, page: 3, random_stuff:7 )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context ".log" do
|
30
|
+
it {expect(@instance).to respond_to :log}
|
31
|
+
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
|
+
end
|
35
|
+
end
|
36
|
+
|
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
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V1::Rules do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V1::Rules)
|
6
|
+
dummy_instance.extend(Auth0::Mixins::Initializer)
|
7
|
+
@instance = dummy_instance
|
8
|
+
end
|
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
|
15
|
+
end
|
16
|
+
end
|
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
|
23
|
+
end
|
24
|
+
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
|
30
|
+
end
|
31
|
+
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
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "securerandom"
|
3
|
+
|
4
|
+
describe Auth0::Api::V1::Users do
|
5
|
+
before :all do
|
6
|
+
dummy_instance = DummyClass.new
|
7
|
+
dummy_instance.extend(Auth0::Api::V1::Users)
|
8
|
+
@instance = dummy_instance
|
9
|
+
end
|
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
|
17
|
+
end
|
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
|
22
|
+
end
|
23
|
+
end
|
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
|
30
|
+
end
|
31
|
+
end
|
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
|
38
|
+
end
|
39
|
+
end
|
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
|
47
|
+
end
|
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
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
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
|
60
|
+
end
|
61
|
+
|
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"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
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
|
73
|
+
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"
|
77
|
+
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")
|
80
|
+
@instance.socialconnections_users
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
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")
|
89
|
+
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
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
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")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
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
|
+
end
|
110
|
+
end
|
111
|
+
|
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
|
115
|
+
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
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
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")
|
126
|
+
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")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
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")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
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")
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
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"}
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
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")
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
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")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
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"}
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
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/")
|
185
|
+
@instance.delete_users
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
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")
|
194
|
+
end
|
195
|
+
|
196
|
+
it "is expected not to call delete to /api/users if user_id is blank" do
|
197
|
+
expect(@instance).not_to receive(:delete)
|
198
|
+
expect{@instance.delete_user("")}.to raise_exception(Auth0::UserIdIsBlank)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
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")
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
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")
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V2::Blacklists do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Blacklists)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context ".blacklisted_tokens" do
|
10
|
+
it {expect(@instance).to respond_to(:blacklisted_tokens)}
|
11
|
+
it "is expected to call /api/v2/blacklists/tokens" do
|
12
|
+
expect(@instance).to receive(:get).with("/api/v2/blacklists/tokens")
|
13
|
+
expect{@instance.blacklisted_tokens}.not_to raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context ".add_token.to_blacklist" do
|
18
|
+
it {expect(@instance).to respond_to(:add_token_to_blacklist)}
|
19
|
+
it "is expected to call post to /api/v2/blacklists/tokens" do
|
20
|
+
expect(@instance).to receive(:post).with("/api/v2/blacklists/tokens", {aud: "aud", jti: "jti"})
|
21
|
+
@instance.add_token_to_blacklist("jti", "aud")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V2::Clients do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Clients)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
context ".clients" do
|
9
|
+
it {expect(@instance).to respond_to(:clients)}
|
10
|
+
it {expect(@instance).to respond_to(:get_clients)}
|
11
|
+
it "is expected to send get request to /api/v2/clients/" do
|
12
|
+
expect(@instance).to receive(:get).with("/api/v2/clients", {})
|
13
|
+
expect{@instance.clients}.not_to raise_error
|
14
|
+
end
|
15
|
+
it "is expected to send get request to /api/v2/clients?fields=name&exclude_fields=false" do
|
16
|
+
expect(@instance).to receive(:get).with("/api/v2/clients",{exclude_fields: false, fields: [:name]})
|
17
|
+
expect{@instance.clients({exclude_fields: false, fields: [:name]})}.not_to raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context ".client" do
|
21
|
+
it {expect(@instance).to respond_to(:client)}
|
22
|
+
it "is expected to send get request to /api/v2/clients/1" do
|
23
|
+
expect(@instance).to receive(:get).with("/api/v2/clients/1", {})
|
24
|
+
expect{@instance.client(1)}.not_to raise_error
|
25
|
+
end
|
26
|
+
it "is expected to send get request to /api/v2/clients?fields=name&exclude_fields=false" do
|
27
|
+
expect(@instance).to receive(:get).with("/api/v2/clients/1",{exclude_fields: false, fields: [:name]})
|
28
|
+
expect{@instance.client(1,{exclude_fields: false, fields: [:name]})}.not_to raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context ".create_client" do
|
33
|
+
it {expect(@instance).to respond_to(:create_client)}
|
34
|
+
it "is expected to send post to /api/v2/clients" do
|
35
|
+
expect(@instance).to receive(:post).with("/api/v2/clients",{name: "name", opt: "opt"})
|
36
|
+
expect{@instance.create_client("name", {name: "/name1", opt: "opt"})}.not_to raise_error
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context ".delete_client" do
|
40
|
+
it {expect(@instance).to respond_to(:delete_client)}
|
41
|
+
it "is expected to send delete to /api/v2/clients/1" do
|
42
|
+
expect(@instance).to receive(:delete).with("/api/v2/clients/1")
|
43
|
+
expect{@instance.delete_client("1")}.not_to raise_error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context ".patch_client" do
|
48
|
+
it {expect(@instance).to respond_to(:patch_client)}
|
49
|
+
it "is expected to send patch to /api/v2/clients/1" do
|
50
|
+
expect(@instance).to receive(:patch).with("/api/v2/clients/1", {fields: "fields"})
|
51
|
+
expect{@instance.patch_client("1", {fields: "fields"})}.not_to raise_error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V2::Jobs do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Jobs)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
context ".get_job" do
|
9
|
+
it{expect(@instance).to respond_to(:get_job)}
|
10
|
+
it "expect client to send get to /api/v2/stats/jobs/3" do
|
11
|
+
expect(@instance).to receive(:get).with("/api/v2/jobs/3")
|
12
|
+
expect{@instance.get_job(3)}.not_to raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
context ".daily_stats" do
|
16
|
+
it{expect(@instance).to respond_to(:create_job)}
|
17
|
+
it "expect client to send get to /api/v2/stats/daily" do
|
18
|
+
expect{@instance.create_job("file_name","name")}.to raise_error(NotImplementedError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe Auth0::Api::V2::Stats do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Stats)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
context ".active_users" do
|
9
|
+
it{expect(@instance).to respond_to(:active_users)}
|
10
|
+
it "expect client to send get to /api/v2/stats/active-users" do
|
11
|
+
expect(@instance).to receive(:get).with("/api/v2/stats/active-users")
|
12
|
+
expect{@instance.active_users}.not_to raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
context ".daily_stats" do
|
16
|
+
it{expect(@instance).to respond_to(:daily_stats)}
|
17
|
+
it "expect client to send get to /api/v2/stats/daily" do
|
18
|
+
expect(@instance).to receive(:get).with("/api/v2/stats/daily", {from: "20120222", to: "20151222"})
|
19
|
+
expect{@instance.daily_stats("20120222","20151222")}.not_to raise_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|