auth0 3.6.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +12 -7
- data/CHANGELOG.md +10 -0
- data/Gemfile +4 -2
- data/Guardfile +13 -10
- data/LICENSE +2 -2
- data/README.md +9 -11
- data/Rakefile +33 -7
- data/auth0.gemspec +12 -12
- data/deploy_documentation.sh +29 -0
- data/doc_config/templates/default/fulldoc/html/css/full_list.css +79 -0
- data/doc_config/templates/default/fulldoc/html/css/style.css +546 -0
- data/doc_config/templates/default/layout/html/breadcrumb.erb +11 -0
- data/doc_config/templates/default/layout/html/footer.erb +115 -0
- data/doc_config/templates/default/layout/html/headers.erb +17 -0
- data/doc_config/templates/default/layout/html/layout.erb +27 -0
- data/lib/auth0.rb +5 -5
- data/lib/auth0/api/authentication_endpoints.rb +264 -46
- data/lib/auth0/api/v1.rb +5 -5
- data/lib/auth0/api/v1/clients.rb +7 -7
- data/lib/auth0/api/v1/connections.rb +9 -10
- data/lib/auth0/api/v1/logs.rb +9 -16
- data/lib/auth0/api/v1/rules.rb +5 -5
- data/lib/auth0/api/v1/users.rb +28 -27
- data/lib/auth0/api/v2.rb +17 -9
- data/lib/auth0/api/v2/blacklists.rb +30 -9
- data/lib/auth0/api/v2/clients.rb +60 -19
- data/lib/auth0/api/v2/connections.rb +63 -10
- data/lib/auth0/api/v2/emails.rb +58 -0
- data/lib/auth0/api/v2/jobs.rb +44 -7
- data/lib/auth0/api/v2/rules.rb +104 -0
- data/lib/auth0/api/v2/stats.rb +22 -5
- data/lib/auth0/api/v2/tenants.rb +39 -0
- data/lib/auth0/api/v2/tickets.rb +58 -0
- data/lib/auth0/api/v2/users.rb +128 -39
- data/lib/auth0/client.rb +8 -6
- data/lib/auth0/exception.rb +29 -23
- data/lib/auth0/mixins.rb +12 -10
- data/lib/auth0/mixins/httparty_proxy.rb +13 -10
- data/lib/auth0/mixins/initializer.rb +25 -27
- data/lib/auth0/version.rb +2 -2
- data/spec/integration/lib/auth0/api/v1/api_clients_spec.rb +2 -4
- data/spec/integration/lib/auth0/api/v1/api_users_spec.rb +25 -32
- data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +14 -0
- data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +61 -6
- data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +68 -42
- data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +71 -0
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +69 -0
- data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +83 -0
- data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +16 -0
- data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +37 -0
- data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +33 -0
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +88 -36
- data/spec/integration/lib/auth0/auth0_client_spec.rb +43 -35
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +253 -47
- data/spec/lib/auth0/api/v1/clients_spec.rb +37 -38
- data/spec/lib/auth0/api/v1/connections_spec.rb +44 -38
- data/spec/lib/auth0/api/v1/logs_spec.rb +24 -24
- data/spec/lib/auth0/api/v1/rules_spec.rb +23 -22
- data/spec/lib/auth0/api/v1/users_spec.rb +153 -130
- data/spec/lib/auth0/api/v2/blacklists_spec.rb +12 -11
- data/spec/lib/auth0/api/v2/clients_spec.rb +38 -33
- data/spec/lib/auth0/api/v2/connections_spec.rb +59 -34
- data/spec/lib/auth0/api/v2/emails_spec.rb +47 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +24 -10
- data/spec/lib/auth0/api/v2/rules_spec.rb +69 -0
- data/spec/lib/auth0/api/v2/stats_spec.rb +11 -11
- data/spec/lib/auth0/api/v2/tenants_spec.rb +25 -0
- data/spec/lib/auth0/api/v2/tickets_spec.rb +31 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +101 -39
- data/spec/lib/auth0/client_spec.rb +46 -58
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +98 -69
- data/spec/lib/auth0/mixins/initializer_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_full.rb +16 -15
- data/spec/spec_helper_unit.rb +5 -5
- data/spec/support/credentials.rb +9 -3
- data/spec/support/dummy_class.rb +7 -1
- data/spec/support/dummy_class_for_proxy.rb +2 -2
- data/spec/support/import_users.json +13 -0
- data/spec/support/stub_response.rb +1 -2
- metadata +78 -41
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Blacklists do
|
3
3
|
before :all do
|
4
4
|
dummy_instance = DummyClass.new
|
@@ -6,19 +6,20 @@ describe Auth0::Api::V2::Blacklists do
|
|
6
6
|
@instance = dummy_instance
|
7
7
|
end
|
8
8
|
|
9
|
-
context
|
10
|
-
it {expect(@instance).to respond_to(:blacklisted_tokens)}
|
11
|
-
it
|
12
|
-
expect(@instance).to receive(:get).with(
|
13
|
-
expect{@instance.blacklisted_tokens}.not_to raise_error
|
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', aud: nil)
|
13
|
+
expect { @instance.blacklisted_tokens }.not_to raise_error
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
18
|
-
it {expect(@instance).to respond_to(:add_token_to_blacklist)}
|
19
|
-
it
|
20
|
-
expect(@instance).to receive(:post).with(
|
21
|
-
@instance.add_token_to_blacklist(
|
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
22
|
end
|
23
|
+
it { expect { @instance.add_token_to_blacklist('', '') }.to raise_error 'Must specify a valid JTI' }
|
23
24
|
end
|
24
25
|
end
|
@@ -1,54 +1,59 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Clients do
|
3
3
|
before :all do
|
4
4
|
dummy_instance = DummyClass.new
|
5
5
|
dummy_instance.extend(Auth0::Api::V2::Clients)
|
6
6
|
@instance = dummy_instance
|
7
7
|
end
|
8
|
-
context
|
9
|
-
it {expect(@instance).to respond_to(:clients)}
|
10
|
-
it {expect(@instance).to respond_to(:get_clients)}
|
11
|
-
it
|
12
|
-
expect(@instance).to receive(:get).with(
|
13
|
-
expect{@instance.clients}.not_to raise_error
|
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', fields: nil, include_fields: nil)
|
13
|
+
expect { @instance.clients }.not_to raise_error
|
14
14
|
end
|
15
|
-
it
|
16
|
-
expect(@instance).to receive(:get).with(
|
17
|
-
expect{@instance.clients(
|
15
|
+
it 'is expected to send get request to /api/v2/clients?fields=name' do
|
16
|
+
expect(@instance).to receive(:get).with('/api/v2/clients', include_fields: true, fields: [:name])
|
17
|
+
expect { @instance.clients(fields: [:name], include_fields: true) }.not_to raise_error
|
18
18
|
end
|
19
19
|
end
|
20
|
-
context
|
21
|
-
it {expect(@instance).to respond_to(:client)}
|
22
|
-
it
|
23
|
-
expect(@instance).to receive(:get).with(
|
24
|
-
expect{@instance.client(1)}.not_to raise_error
|
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', fields: nil, include_fields: nil)
|
24
|
+
expect { @instance.client(1) }.not_to raise_error
|
25
25
|
end
|
26
|
-
it
|
27
|
-
expect(@instance).to receive(:get).with(
|
28
|
-
expect{@instance.client(1,
|
26
|
+
it 'is expected to send get request to /api/v2/clients?fields=name&include_fields=true' do
|
27
|
+
expect(@instance).to receive(:get).with('/api/v2/clients/1', include_fields: true, fields: [:name])
|
28
|
+
expect { @instance.client(1, include_fields: true, fields: [:name]) }.not_to raise_error
|
29
29
|
end
|
30
|
+
it { expect { @instance.client('') }.to raise_error 'Must specify a client id' }
|
30
31
|
end
|
31
32
|
|
32
|
-
context
|
33
|
-
it {expect(@instance).to respond_to(:create_client)}
|
34
|
-
it
|
35
|
-
expect(@instance).to receive(:post).with(
|
36
|
-
expect{@instance.create_client(
|
33
|
+
context '.create_client' do
|
34
|
+
it { expect(@instance).to respond_to(:create_client) }
|
35
|
+
it 'is expected to send post to /api/v2/clients' do
|
36
|
+
expect(@instance).to receive(:post).with('/api/v2/clients', name: 'name', opt: 'opt')
|
37
|
+
expect { @instance.create_client('name', name: '/name1', opt: 'opt') }.not_to raise_error
|
37
38
|
end
|
39
|
+
it { expect { @instance.create_client('') }.to raise_error 'Must specify a valid client name' }
|
38
40
|
end
|
39
|
-
context
|
40
|
-
it {expect(@instance).to respond_to(:delete_client)}
|
41
|
-
it
|
42
|
-
expect(@instance).to receive(:delete).with(
|
43
|
-
expect{@instance.delete_client(
|
41
|
+
context '.delete_client' do
|
42
|
+
it { expect(@instance).to respond_to(:delete_client) }
|
43
|
+
it 'is expected to send delete to /api/v2/clients/1' do
|
44
|
+
expect(@instance).to receive(:delete).with('/api/v2/clients/1')
|
45
|
+
expect { @instance.delete_client('1') }.not_to raise_error
|
44
46
|
end
|
47
|
+
it { expect { @instance.delete_client('') }.to raise_error 'Must specify a client id' }
|
45
48
|
end
|
46
49
|
|
47
|
-
context
|
48
|
-
it {expect(@instance).to respond_to(:patch_client)}
|
49
|
-
it
|
50
|
-
expect(@instance).to receive(:patch).with(
|
51
|
-
expect{@instance.patch_client(
|
50
|
+
context '.patch_client' do
|
51
|
+
it { expect(@instance).to respond_to(:patch_client) }
|
52
|
+
it 'is expected to send patch to /api/v2/clients/1' do
|
53
|
+
expect(@instance).to receive(:patch).with('/api/v2/clients/1', fields: 'fields')
|
54
|
+
expect { @instance.patch_client('1', fields: 'fields') }.not_to raise_error
|
52
55
|
end
|
56
|
+
it { expect { @instance.patch_client('', nil) }.to raise_error 'Must specify a client id' }
|
57
|
+
it { expect { @instance.patch_client('some', nil) }.to raise_error 'Must specify a valid body' }
|
53
58
|
end
|
54
59
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Connections do
|
3
3
|
before :all do
|
4
4
|
dummy_instance = DummyClass.new
|
@@ -6,65 +6,90 @@ describe Auth0::Api::V2::Connections do
|
|
6
6
|
@instance = dummy_instance
|
7
7
|
end
|
8
8
|
|
9
|
-
context
|
10
|
-
it {expect(@instance).to respond_to(:connections)}
|
11
|
-
it {expect(@instance).to respond_to(:get_connections)}
|
9
|
+
context '.connections' do
|
10
|
+
it { expect(@instance).to respond_to(:connections) }
|
11
|
+
it { expect(@instance).to respond_to(:get_connections) }
|
12
12
|
|
13
|
-
it
|
14
|
-
expect(@instance).to receive(:get).with(
|
13
|
+
it 'is expected to call /api/v2/connections' do
|
14
|
+
expect(@instance).to receive(:get).with(
|
15
|
+
'/api/v2/connections',
|
15
16
|
strategy: nil,
|
16
17
|
fields: nil,
|
17
|
-
include_fields: true
|
18
|
-
}
|
19
|
-
|
20
|
-
expect{@instance.connections}.not_to raise_error
|
18
|
+
include_fields: true)
|
19
|
+
expect { @instance.connections }.not_to raise_error
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
context '.create_connection' do
|
25
|
-
it {expect(@instance).to respond_to(:connection)}
|
26
|
-
it {expect(@instance).to respond_to(:create_connection)}
|
24
|
+
it { expect(@instance).to respond_to(:connection) }
|
25
|
+
it { expect(@instance).to respond_to(:create_connection) }
|
27
26
|
|
28
|
-
it
|
27
|
+
it 'is expected to call /api/v2/connections' do
|
29
28
|
body = double
|
30
|
-
expect(@instance).to receive(:post).with(
|
29
|
+
expect(@instance).to receive(:post).with('/api/v2/connections', body)
|
30
|
+
expect { @instance.create_connection(body) }.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'is expected to raise an error when calling with empty body' do
|
34
|
+
expect(@instance).not_to receive(:post)
|
35
|
+
expect { @instance.create_connection(nil) }.to raise_error 'Must specify a body to create a connection'
|
36
|
+
end
|
37
|
+
end
|
31
38
|
|
32
|
-
|
39
|
+
context '.connection' do
|
40
|
+
it { expect(@instance).to respond_to(:connection) }
|
41
|
+
it 'is expected to call get request to /api/v2/connection/connectionId' do
|
42
|
+
expect(@instance).to receive(:get).with('/api/v2/connections/connectionId', fields: nil, include_fields: true)
|
43
|
+
expect { @instance.connection('connectionId') }.not_to raise_error
|
44
|
+
end
|
45
|
+
it 'is expected raise an error when calling with empty id' do
|
46
|
+
expect(@instance).not_to receive(:get)
|
47
|
+
expect { @instance.connection(nil) }.to raise_error 'Must supply a valid connection id'
|
33
48
|
end
|
34
49
|
end
|
35
50
|
|
36
|
-
context
|
37
|
-
it {expect(@instance).to respond_to(:
|
38
|
-
it
|
39
|
-
expect(@instance).to receive(:
|
40
|
-
|
51
|
+
context '.delete_connection' do
|
52
|
+
it { expect(@instance).to respond_to(:delete_connection) }
|
53
|
+
it 'is expected to call delete to /api/v2/connections/connectionId' do
|
54
|
+
expect(@instance).to receive(:delete).with('/api/v2/connections/connectionId')
|
55
|
+
@instance.delete_connection('connectionId')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'is expected raise an error when calling with empty id' do
|
59
|
+
expect(@instance).not_to receive(:delete)
|
60
|
+
expect { @instance.delete_connection(nil) }.to raise_error 'Must supply a valid connection id'
|
41
61
|
end
|
42
62
|
end
|
43
63
|
|
44
|
-
context
|
45
|
-
it {expect(@instance).to respond_to(:
|
46
|
-
it
|
47
|
-
expect(@instance).to receive(:delete).with(
|
48
|
-
@instance.
|
64
|
+
context '.delete_connection_user' do
|
65
|
+
it { expect(@instance).to respond_to(:delete_connection_user) }
|
66
|
+
it 'is expected to call delete to /api/v2/connections/connectionId/users' do
|
67
|
+
expect(@instance).to receive(:delete).with('/api/v2/connections/connectionId/users?email=email@test.com')
|
68
|
+
@instance.delete_connection_user('connectionId', 'email@test.com')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'is expected raise an error when calling with empty id' do
|
72
|
+
expect(@instance).not_to receive(:delete)
|
73
|
+
expect { @instance.delete_connection_user(nil, nil) }.to raise_error 'Must supply a valid connection id'
|
49
74
|
end
|
50
75
|
|
51
|
-
it
|
76
|
+
it 'is expected raise an error when calling with empty email' do
|
52
77
|
expect(@instance).not_to receive(:delete)
|
53
|
-
expect{@instance.
|
78
|
+
expect { @instance.delete_connection_user('Connection ID', nil) }.to raise_error 'Must supply a valid user email'
|
54
79
|
end
|
55
80
|
end
|
56
81
|
|
57
|
-
context
|
58
|
-
it {expect(@instance).to respond_to(:update_connection)}
|
59
|
-
it
|
82
|
+
context '.update_connection' do
|
83
|
+
it { expect(@instance).to respond_to(:update_connection) }
|
84
|
+
it 'is expected to call patch to /api/v2/connections/connectionId' do
|
60
85
|
body = double
|
61
|
-
expect(@instance).to receive(:patch).with(
|
62
|
-
@instance.update_connection(
|
86
|
+
expect(@instance).to receive(:patch).with('/api/v2/connections/connectionId', body)
|
87
|
+
@instance.update_connection('connectionId', body)
|
63
88
|
end
|
64
89
|
|
65
|
-
it
|
90
|
+
it 'is expected raise an error when calling with empty id' do
|
66
91
|
expect(@instance).not_to receive(:patch)
|
67
|
-
expect{@instance.delete_connection(
|
92
|
+
expect { @instance.delete_connection(nil) }.to raise_error 'Must supply a valid connection id'
|
68
93
|
end
|
69
94
|
end
|
70
95
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Emails do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Emails)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.get_email' do
|
10
|
+
it { expect(@instance).to respond_to(:get_provider) }
|
11
|
+
it 'expect client to send get to /api/v2/emails/provider with fields' do
|
12
|
+
expect(@instance).to receive(:get).with('/api/v2/emails/provider', fields: 'some', include_fields: true)
|
13
|
+
expect { @instance.get_provider(fields: 'some', include_fields: true) }.not_to raise_error
|
14
|
+
end
|
15
|
+
it 'expect client to send get to /api/v2/emails/provider with empty fields' do
|
16
|
+
expect(@instance).to receive(:get).with('/api/v2/emails/provider', fields: nil, include_fields: nil)
|
17
|
+
expect { @instance.get_provider }.not_to raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context '.configure_email' do
|
21
|
+
it { expect(@instance).to respond_to(:configure_provider) }
|
22
|
+
it 'expect client to send post to /api/v2/emails/provider' do
|
23
|
+
expect(@instance).to receive(:post).with('/api/v2/emails/provider', 'test body')
|
24
|
+
expect { @instance.configure_provider('test body') }.not_to raise_error
|
25
|
+
end
|
26
|
+
it 'expect client to raise an error when calling with empty body' do
|
27
|
+
expect { @instance.configure_provider(nil) }.to raise_error 'Must supply a valid body to create an email provider'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
context '.delete_email' do
|
31
|
+
it { expect(@instance).to respond_to(:delete_provider) }
|
32
|
+
it 'expect client to send delete to /api/v2/emails/provider' do
|
33
|
+
expect(@instance).to receive(:delete).with('/api/v2/emails/provider')
|
34
|
+
expect { @instance.delete_provider }.not_to raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
context '.patch_email' do
|
38
|
+
it { expect(@instance).to respond_to(:update_provider) }
|
39
|
+
it 'expect client to send patch to /api/v2/emails/provider' do
|
40
|
+
expect(@instance).to receive(:patch).with('/api/v2/emails/provider', 'test body')
|
41
|
+
expect { @instance.update_provider('test body') }.not_to raise_error
|
42
|
+
end
|
43
|
+
it 'expect client to raise an error when calling with empty body' do
|
44
|
+
expect { @instance.update_provider(nil) }.to raise_error 'Must supply a valid body to update an email provider'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,21 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Jobs do
|
3
3
|
before :all do
|
4
4
|
dummy_instance = DummyClass.new
|
5
5
|
dummy_instance.extend(Auth0::Api::V2::Jobs)
|
6
6
|
@instance = dummy_instance
|
7
7
|
end
|
8
|
-
context
|
9
|
-
it{expect(@instance).to respond_to(:get_job)}
|
10
|
-
it
|
11
|
-
expect(@instance).to receive(:get).with(
|
12
|
-
expect{@instance.get_job(3)}.not_to raise_error
|
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
13
|
end
|
14
|
+
it { expect { @instance.get_job('') }.to raise_error('Must specify a job id') }
|
14
15
|
end
|
15
|
-
context
|
16
|
-
it{expect(@instance).to respond_to(:
|
17
|
-
it
|
18
|
-
expect
|
16
|
+
context '.import_users' do
|
17
|
+
it { expect(@instance).to respond_to(:import_users) }
|
18
|
+
it 'expect client to send post to /api/v2/jobs/users-imports' do
|
19
|
+
expect(@instance).to receive(:post_file).with(
|
20
|
+
'/api/v2/jobs/users-imports', users: 'file', connection_id: 'connnection_id')
|
21
|
+
expect { @instance.import_users('file', 'connnection_id') }.not_to raise_error
|
19
22
|
end
|
23
|
+
it { expect { @instance.import_users('', 'connnection_id') }.to raise_error('Must specify a valid file') }
|
24
|
+
it { expect { @instance.import_users('users', '') }.to raise_error('Must specify a connection_id') }
|
25
|
+
end
|
26
|
+
|
27
|
+
context '.send_verification_email' do
|
28
|
+
it { expect(@instance).to respond_to(:send_verification_email) }
|
29
|
+
it 'expect client to send post to /api/v2/jobs/verification-email' do
|
30
|
+
expect(@instance).to receive(:post).with('/api/v2/jobs/verification-email', user_id: 'user_id')
|
31
|
+
expect { @instance.send_verification_email(user_id: 'user_id') }.not_to raise_error
|
32
|
+
end
|
33
|
+
it { expect { @instance.send_verification_email('') }.to raise_error('Must specify a user id') }
|
20
34
|
end
|
21
35
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Rules do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::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/v2/rules' do
|
13
|
+
expect(@instance).to receive(:get).with(
|
14
|
+
'/api/v2/rules', enabled: nil, fields: nil, include_fields: nil, stage: nil)
|
15
|
+
expect { @instance.rules }.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '.rule' do
|
20
|
+
it { expect(@instance).to respond_to(:rule) }
|
21
|
+
it 'is expected to call get /api/v2/rules/test' do
|
22
|
+
expect(@instance).to receive(:get).with(
|
23
|
+
'/api/v2/rules/test', fields: nil, include_fields: nil)
|
24
|
+
expect { @instance.rule('test') }.not_to raise_error
|
25
|
+
end
|
26
|
+
it 'expect to raise an error when calling with empty rule id' do
|
27
|
+
expect { @instance.rule(nil) }.to raise_error 'Must supply a valid rule id'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context '.create_rule' do
|
32
|
+
it { expect(@instance).to respond_to(:create_rule) }
|
33
|
+
it 'is expected to call post /api/v2/rules' do
|
34
|
+
expect(@instance).to receive(:post).with(
|
35
|
+
'/api/v2/rules',
|
36
|
+
name: 'test', script: 'script', order: 'order', enabled: false, stage: 'login_success')
|
37
|
+
expect { @instance.create_rule('test', 'script', 'order', false) }.not_to raise_error
|
38
|
+
end
|
39
|
+
it 'expect to raise an error when calling with empty name' do
|
40
|
+
expect { @instance.create_rule(nil, 'script') }.to raise_error 'Must supply a valid name'
|
41
|
+
end
|
42
|
+
it 'expect to raise an error when calling with empty script' do
|
43
|
+
expect { @instance.create_rule('test', nil) }.to raise_error 'Must supply a valid script'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
context '.update_rule' do
|
47
|
+
it { expect(@instance).to respond_to(:update_rule) }
|
48
|
+
it 'is expected to call put /api/v2/rules/test' do
|
49
|
+
expect(@instance).to receive(:patch).with(
|
50
|
+
'/api/v2/rules/test', script: 'script', order: 'order', enabled: true, stage: 'some_stage')
|
51
|
+
expect do
|
52
|
+
@instance.update_rule('test', script: 'script', order: 'order', enabled: true, stage: 'some_stage')
|
53
|
+
end.not_to raise_error
|
54
|
+
end
|
55
|
+
it 'expect to raise an error when calling with empty rule id' do
|
56
|
+
expect { @instance.update_rule(nil, 'test') }.to raise_error 'Must supply a valid rule id'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
context '.delete_rule' do
|
60
|
+
it { expect(@instance).to respond_to(:delete_rule) }
|
61
|
+
it 'is expected to call delete /api/v2/rules/test' do
|
62
|
+
expect(@instance).to receive(:delete).with('/api/v2/rules/test')
|
63
|
+
expect { @instance.delete_rule('test') }.not_to raise_error
|
64
|
+
end
|
65
|
+
it 'expect to raise an error when calling with empty rule id' do
|
66
|
+
expect { @instance.delete_rule(nil) }.to raise_error 'Must supply a valid rule id'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Stats do
|
3
3
|
before :all do
|
4
4
|
dummy_instance = DummyClass.new
|
5
5
|
dummy_instance.extend(Auth0::Api::V2::Stats)
|
6
6
|
@instance = dummy_instance
|
7
7
|
end
|
8
|
-
context
|
9
|
-
it{expect(@instance).to respond_to(:active_users)}
|
10
|
-
it
|
11
|
-
expect(@instance).to receive(:get).with(
|
12
|
-
expect{@instance.active_users}.not_to raise_error
|
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
13
|
end
|
14
14
|
end
|
15
|
-
context
|
16
|
-
it{expect(@instance).to respond_to(:daily_stats)}
|
17
|
-
it
|
18
|
-
expect(@instance).to receive(:get).with(
|
19
|
-
expect{@instance.daily_stats(
|
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
20
|
end
|
21
21
|
end
|
22
22
|
end
|