auth0 4.14.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.yardoc/checksums +22 -0
  4. data/.yardoc/complete +0 -0
  5. data/.yardoc/object_types +0 -0
  6. data/.yardoc/objects/root.dat +0 -0
  7. data/.yardoc/proxy_types +0 -0
  8. data/CHANGELOG.md +73 -0
  9. data/Gemfile +0 -1
  10. data/Gemfile.lock +34 -39
  11. data/README.md +5 -7
  12. data/Rakefile +0 -22
  13. data/auth0.gemspec +1 -1
  14. data/examples/ruby-api/.gitignore +0 -6
  15. data/lib/auth0/api/authentication_endpoints.rb +6 -220
  16. data/lib/auth0/api/v2.rb +2 -0
  17. data/lib/auth0/api/v2/jobs.rb +11 -1
  18. data/lib/auth0/api/v2/log_streams.rb +78 -0
  19. data/lib/auth0/api/v2/tickets.rb +12 -1
  20. data/lib/auth0/api/v2/users.rb +20 -7
  21. data/lib/auth0/exception.rb +2 -7
  22. data/lib/auth0/mixins.rb +0 -1
  23. data/lib/auth0/mixins/access_token_struct.rb +2 -2
  24. data/lib/auth0/mixins/api_token_struct.rb +2 -2
  25. data/lib/auth0/mixins/httpproxy.rb +3 -1
  26. data/lib/auth0/mixins/initializer.rb +1 -7
  27. data/lib/auth0/mixins/permission_struct.rb +2 -2
  28. data/lib/auth0/mixins/validation.rb +1 -1
  29. data/lib/auth0/version.rb +1 -1
  30. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +1 -1
  31. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +12 -0
  32. data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +1 -1
  33. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +7 -1
  34. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +1 -1
  35. data/spec/lib/auth0/api/v2/jobs_spec.rb +17 -0
  36. data/spec/lib/auth0/api/v2/log_streams_spec.rb +84 -0
  37. data/spec/lib/auth0/api/v2/roles_spec.rb +4 -4
  38. data/spec/lib/auth0/api/v2/tickets_spec.rb +17 -0
  39. data/spec/lib/auth0/api/v2/users_spec.rb +37 -10
  40. data/spec/lib/auth0/mixins/httpproxy_spec.rb +2 -2
  41. data/spec/support/credentials.rb +0 -19
  42. metadata +31 -38
  43. data/deploy_documentation.sh +0 -29
  44. data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
  45. data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
  46. data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
  47. data/doc_config/templates/default/layout/html/footer.erb +0 -115
  48. data/doc_config/templates/default/layout/html/headers.erb +0 -17
  49. data/doc_config/templates/default/layout/html/layout.erb +0 -27
  50. data/lib/auth0/api/v1.rb +0 -19
  51. data/lib/auth0/api/v1/clients.rb +0 -58
  52. data/lib/auth0/api/v1/connections.rb +0 -68
  53. data/lib/auth0/api/v1/logs.rb +0 -43
  54. data/lib/auth0/api/v1/rules.rb +0 -57
  55. data/lib/auth0/api/v1/users.rb +0 -227
  56. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -703
@@ -16,6 +16,7 @@ require 'auth0/api/v2/user_blocks'
16
16
  require 'auth0/api/v2/tenants'
17
17
  require 'auth0/api/v2/tickets'
18
18
  require 'auth0/api/v2/logs'
19
+ require 'auth0/api/v2/log_streams'
19
20
  require 'auth0/api/v2/resource_servers'
20
21
  require 'auth0/api/v2/guardian'
21
22
 
@@ -41,6 +42,7 @@ module Auth0
41
42
  include Auth0::Api::V2::Tenants
42
43
  include Auth0::Api::V2::Tickets
43
44
  include Auth0::Api::V2::Logs
45
+ include Auth0::Api::V2::LogStreams
44
46
  include Auth0::Api::V2::ResourceServers
45
47
  include Auth0::Api::V2::Guardian
46
48
  end
@@ -78,14 +78,24 @@ module Auth0
78
78
  # @see https://auth0.com/docs/api/management/v2#!/Jobs/post_verification_email
79
79
  # @param user_id [string] The user_id of the user to whom the email will be sent.
80
80
  # @param client_id [string] Client ID to send an Application-specific email.
81
+ # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
82
+ # * :user_id [string] user_id of the identity.
83
+ # * :provider [string] provider of the identity.
81
84
  #
82
85
  # @return [json] Returns the job status and properties.
83
- def send_verification_email(user_id, client_id = nil)
86
+ def send_verification_email(user_id, client_id = nil, identity: nil)
84
87
  raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
85
88
 
86
89
  request_params = { user_id: user_id }
87
90
  request_params[:client_id] = client_id unless client_id.nil?
88
91
 
92
+ if identity
93
+ unless identity.is_a? Hash
94
+ raise Auth0::InvalidParameter, 'Identity must be a hash send an email verification'
95
+ end
96
+ request_params[:identity] = identity
97
+ end
98
+
89
99
  path = "#{jobs_path}/verification-email"
90
100
  post(path, request_params)
91
101
  end
@@ -0,0 +1,78 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the log streams endpoints
5
+ module LogStreams
6
+ attr_reader :log_streams_path
7
+
8
+ # Retrieves a list of all log streams.
9
+ # @see https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams
10
+ # @return [json] Returns the log streams.
11
+ def log_streams()
12
+ get(log_streams_path)
13
+ end
14
+ alias get_log_streams log_streams
15
+
16
+ # Retrieves a log stream by its ID.
17
+ # @see https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams_by_id
18
+ # @param id [string] The id of the log stream to retrieve.
19
+ #
20
+ # @return [json] Returns the log stream.
21
+ def log_stream(id)
22
+ raise Auth0::InvalidParameter, 'Must supply a valid log stream id' if id.to_s.empty?
23
+ path = "#{log_streams_path}/#{id}"
24
+ get(path)
25
+ end
26
+ alias get_log_stream log_stream
27
+
28
+ # Creates a new log stream according to the JSON object received in body.
29
+ # @see https://auth0.com/docs/api/management/v2#!/Log_Streams/post_log_streams
30
+ # @param name [string] The name of the log stream.
31
+ # @param type [string] The type of log stream
32
+ # @param options [hash] The Hash options used to define the log streams's properties.
33
+ #
34
+ # @return [json] Returns the log stream.
35
+ def create_log_stream(name, type, options)
36
+ raise Auth0::InvalidParameter, 'Name must contain at least one character' if name.to_s.empty?
37
+ raise Auth0::InvalidParameter, 'Must specify a valid type' if type.to_s.empty?
38
+ raise Auth0::InvalidParameter, 'Must supply a valid hash for options' unless options.is_a? Hash
39
+
40
+ request_params = {}
41
+ request_params[:name] = name
42
+ request_params[:type] = type
43
+ request_params[:sink] = options
44
+ post(log_streams_path, request_params)
45
+ end
46
+
47
+ # Deletes a log stream by its ID.
48
+ # @see https://auth0.com/docs/api/management/v2#!/Log_Streams/delete_log_streams_by_id
49
+ # @param id [string] The id of the log stream to delete.
50
+ def delete_log_stream(id)
51
+ raise Auth0::InvalidParameter, 'Must supply a valid log stream id' if id.to_s.empty?
52
+ path = "#{log_streams_path}/#{id}"
53
+ delete(path)
54
+ end
55
+
56
+ # Updates a log stream.
57
+ # @see https://auth0.com/docs/api/management/v2#!/Log_Streams/patch_log_streams_by_id
58
+ # @param id [string] The id or audience of the log stream to update.
59
+ # @param status [string] The Hash options used to define the log streams's properties.
60
+ def patch_log_stream(id, status)
61
+ raise Auth0::InvalidParameter, 'Must specify a log stream id' if id.to_s.empty?
62
+ raise Auth0::InvalidParameter, 'Must specify a valid status' if status.to_s.empty?
63
+
64
+ request_params = {}
65
+ request_params[:status] = status
66
+ path = "#{log_streams_path}/#{id}"
67
+ patch(path, request_params)
68
+ end
69
+
70
+ private
71
+ # Log Streams API path
72
+ def log_streams_path
73
+ @log_streams_path ||= '/api/v2/log-streams'
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -12,9 +12,12 @@ module Auth0
12
12
  # @param ttl_sec [integer] The ticket's lifetime in seconds starting from the moment of creation.
13
13
  # After expiration, the ticket cannot be used to verify the user's email. If not specified or if
14
14
  # you send 0, the Auth0 default lifetime of five days will be applied
15
+ # @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
16
+ # * :user_id [string] user_id of the identity.
17
+ # * :provider [string] provider of the identity.
15
18
  #
16
19
  # @return [json] Returns the created ticket url.
17
- def post_email_verification(user_id, result_url: nil, ttl_sec: nil)
20
+ def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil)
18
21
  if user_id.to_s.empty?
19
22
  raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
20
23
  end
@@ -24,6 +27,14 @@ module Auth0
24
27
  result_url: result_url,
25
28
  ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
26
29
  }
30
+
31
+ if identity
32
+ unless identity.is_a? Hash
33
+ raise Auth0::InvalidParameter, 'Identity must be a hash to post an email verification'
34
+ end
35
+ request_params[:identity] = identity
36
+ end
37
+
27
38
  post(path, request_params)
28
39
  end
29
40
 
@@ -43,13 +43,15 @@ module Auth0
43
43
  # The attribute connection is always mandatory but depending on the type of connection you are using there
44
44
  # could be others too. For instance, Auth0 DB Connections require email and password.
45
45
  # @see https://auth0.com/docs/api/v2#!/Users/post_users
46
- # @param name [string] The user name.
47
- # @param options [hash]
48
- # * :connection [string] The connection the user belongs to.
46
+ # @param connection [string] The connection the user belongs to.
47
+ # @param options [hash] See https://auth0.com/docs/api/management/v2#!/Users/post_users for available options
49
48
  # @return [json] Returns the created user.
50
- def create_user(name, options = {})
49
+ def create_user(connection, options = {})
50
+ if !connection.is_a?(String) || connection.empty?
51
+ raise Auth0::MissingParameter, 'Must supply a valid connection'
52
+ end
51
53
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
52
- request_params[:name] = name
54
+ request_params[:connection] = connection
53
55
  post(users_path, request_params)
54
56
  end
55
57
 
@@ -248,11 +250,22 @@ module Auth0
248
250
  # @see https://auth0.com/docs/api/management/v2#!/Users/get_permissions
249
251
  #
250
252
  # @param user_id [string] The user_id of the permissions to get.
253
+ # @param options [hash] A hash of options for getting permissions
254
+ # * :per_page [integer] The amount of permissions per page. (optional)
255
+ # * :page [integer] The page number. Zero based. (optional)
256
+ # * :include_totals [boolean] True if a query summary must be included in the result. (optional)
251
257
  #
252
258
  # @return [json] Returns permissions for the given user_id.
253
- def get_user_permissions(user_id)
259
+ def get_user_permissions(user_id, options = {})
254
260
  raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
255
- get "#{users_path}/#{user_id}/permissions"
261
+
262
+ request_params = {
263
+ per_page: options.fetch(:per_page, nil),
264
+ page: options.fetch(:page, nil),
265
+ include_totals: options.fetch(:include_totals, nil)
266
+ }
267
+
268
+ get "#{users_path}/#{user_id}/permissions", request_params
256
269
  end
257
270
 
258
271
  # Remove one or more permissions from a specific user.
@@ -44,17 +44,12 @@ module Auth0
44
44
  class AccessDenied < Auth0::HTTPError; end
45
45
  # Invalid parameter passed, e.g. empty where ID is required
46
46
  class InvalidParameter < Auth0::Exception; end
47
- # Invalid Auth0 credentials either client_id/secret for API v1
48
- # or JWT for API v2/
47
+ # Invalid JWT
49
48
  class InvalidCredentials < Auth0::Exception; end
50
49
  # Invalid Auth0 API namespace
51
50
  class InvalidApiNamespace < Auth0::Exception; end
52
51
  # Auth0 API rate-limiting encountered
53
- # TODO: When making API-breaking changes, make this a subclass
54
- # of Auth0::HTTPError directly rather than Auth0::Unsupported.
55
- # It's currently under Unsupported to avoid breaking compatibility
56
- # with prior gem versions that treated 429 errors as unknown errors.
57
- class RateLimitEncountered < Auth0::Unsupported
52
+ class RateLimitEncountered < Auth0::HTTPError
58
53
  def reset
59
54
  Time.at(headers['X-RateLimit-Reset']).utc
60
55
  end
@@ -11,7 +11,6 @@ require 'auth0/mixins/permission_struct'
11
11
  require 'auth0/mixins/validation'
12
12
 
13
13
  require 'auth0/api/authentication_endpoints'
14
- require 'auth0/api/v1'
15
14
  require 'auth0/api/v2'
16
15
 
17
16
  module Auth0
@@ -1,4 +1,4 @@
1
- AccessToken = Struct.new(
1
+ Auth0::AccessToken = Struct.new(
2
2
  :access_token,
3
3
  :expires_in,
4
4
  :refresh_token,
@@ -17,4 +17,4 @@ AccessToken = Struct.new(
17
17
  def token
18
18
  access_token
19
19
  end
20
- end
20
+ end
@@ -1,4 +1,4 @@
1
- ApiToken = Struct.new :access_token, :scope, :expires_in do
1
+ Auth0::ApiToken = Struct.new :access_token, :scope, :expires_in do
2
2
 
3
3
  def token
4
4
  access_token
@@ -7,4 +7,4 @@ ApiToken = Struct.new :access_token, :scope, :expires_in do
7
7
  def scopes
8
8
  scope.split
9
9
  end
10
- end
10
+ end
@@ -1,3 +1,5 @@
1
+ require "addressable/uri"
2
+
1
3
  module Auth0
2
4
  module Mixins
3
5
  # here's the proxy for Rest calls based on rest-client, we're building all request on that gem
@@ -8,7 +10,7 @@ module Auth0
8
10
  # proxying requests from instance methods to HTTP class methods
9
11
  %i(get post post_file put patch delete delete_with_body).each do |method|
10
12
  define_method(method) do |path, body = {}, extra_headers = {}|
11
- safe_path = URI.escape(path)
13
+ safe_path = Addressable::URI.escape(path)
12
14
  body = body.delete_if { |_, v| v.nil? }
13
15
  result = if method == :get
14
16
  # Mutate the headers property to add parameters.
@@ -40,7 +40,7 @@ module Auth0
40
40
  private
41
41
 
42
42
  def initialize_api(options)
43
- api_v2?(options) ? initialize_v2(options) : initialize_v1
43
+ initialize_v2(options)
44
44
  raise InvalidCredentials, 'Must supply a valid API token' if @token.nil?
45
45
  if options.fetch(:authorization, nil) == 'Basic'
46
46
  authorization_header_basic(options)
@@ -61,12 +61,6 @@ module Auth0
61
61
  @token = api_token.token if @token.nil? && @client_id && @client_secret
62
62
  end
63
63
 
64
- def initialize_v1
65
- extend Auth0::Api::V1
66
- raise InvalidCredentials, 'Invalid API v1 client_id and client_secret' if @client_id.nil? || @client_secret.nil?
67
- @token = obtain_access_token
68
- end
69
-
70
64
  def api_v2?(options)
71
65
  version = options[:api_version] || 2
72
66
  protocol = options[:protocols].to_s
@@ -1,3 +1,3 @@
1
- Permission = Struct.new :permission_name, :resource_server_identifier do
1
+ Auth0::Permission = Struct.new :permission_name, :resource_server_identifier do
2
2
 
3
- end
3
+ end
@@ -23,7 +23,7 @@ module Auth0
23
23
  raise Auth0::InvalidParameter, 'Must supply an array of Permissions' unless permissions.kind_of?(Array)
24
24
  raise Auth0::MissingParameter, 'Must supply an array of Permissions' if permissions.empty?
25
25
  raise Auth0::InvalidParameter, 'All array elements must be Permissions' unless permissions.all? do |permission|
26
- permission.kind_of? Permission
26
+ permission.kind_of? ::Auth0::Permission
27
27
  end
28
28
  permissions.map { |permission| permission.to_h }
29
29
  end
@@ -1,4 +1,4 @@
1
1
  # current version of gem
2
2
  module Auth0
3
- VERSION = '4.14.0'.freeze
3
+ VERSION = '5.0.0'.freeze
4
4
  end
@@ -60,7 +60,7 @@ describe Auth0::Api::AuthenticationEndpoints do
60
60
  end
61
61
 
62
62
  it 'should return the userinfo' do
63
- tokens = @client.login(test_user_email, test_user_pwd, nil, nil)
63
+ tokens = @client.login_with_resource_owner(test_user_email, test_user_pwd)
64
64
  expect(@client.userinfo(tokens['access_token'])).to(
65
65
  include( 'email' => test_user_email )
66
66
  )
@@ -100,6 +100,18 @@ describe Auth0::Api::V2::Jobs do
100
100
  client.send_verification_email(user['user_id'], Random.new(32).to_s)
101
101
  end.to raise_error Auth0::BadRequest
102
102
  end
103
+
104
+ it 'should raise an error if the user id is empty' do
105
+ expect do
106
+ client.send_verification_email( '' )
107
+ end.to raise_error Auth0::InvalidParameter, 'Must specify a user id'
108
+ end
109
+
110
+ it 'should raise an error if the identity supplied is not a Hash' do
111
+ expect do
112
+ client.send_verification_email( 'user_id', identity: 'not a hash')
113
+ end.to raise_error Auth0::InvalidParameter, 'Identity must be a hash send an email verification'
114
+ end
103
115
  end
104
116
 
105
117
  after(:all) do
@@ -14,7 +14,7 @@ describe Auth0::Api::V2::Roles do
14
14
  @test_role_name = "#{entity_suffix}-test-role"
15
15
 
16
16
  @test_permission_name = "#{entity_suffix}-test-permission"
17
- @test_permission = Permission.new(@test_permission_name, @test_api_name)
17
+ @test_permission = ::Auth0::Permission.new(@test_permission_name , @test_api_name)
18
18
 
19
19
  VCR.use_cassette('Auth0_Api_V2_Roles/create_test_user') do
20
20
  @test_user ||= client.create_user(
@@ -35,7 +35,13 @@ describe Auth0::Api::V2::Tickets do
35
35
  it 'should raise an error if the user id is empty' do
36
36
  expect do
37
37
  client.post_email_verification( '' )
38
- end.to raise_error Auth0::InvalidParameter
38
+ end.to raise_error Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
39
+ end
40
+
41
+ it 'should raise an error if the identity supplied is not a Hash' do
42
+ expect do
43
+ client.post_email_verification( '', identity: 'not a hash')
44
+ end.to raise_error Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
39
45
  end
40
46
  end
41
47
 
@@ -14,7 +14,7 @@ describe Auth0::Api::V2::Users do
14
14
  @test_api_scope = 'test:scope'
15
15
 
16
16
  @test_permission_name = "#{entity_suffix}-test-permission-for-users"
17
- @test_permission = Permission.new("#{entity_suffix}-test-permission-for-users", @test_api_name)
17
+ @test_permission = ::Auth0::Permission.new("#{entity_suffix}-test-permission-for-users", @test_api_name)
18
18
 
19
19
  VCR.use_cassette('Auth0_Api_V2_Users/create_test_user') do
20
20
  @test_user ||= client.create_user(
@@ -102,6 +102,23 @@ describe Auth0::Api::V2::Jobs do
102
102
  end.not_to raise_error
103
103
  end
104
104
 
105
+ it 'expect client to accept hash identity' do
106
+ expect(@instance).to receive(:post).with('/api/v2/jobs/verification-email', user_id: 'user_id',
107
+ identity: {
108
+ provider: "auth0",
109
+ user_id: "user_id"
110
+ })
111
+ expect {
112
+ @instance.send_verification_email('user_id', identity: { provider: "auth0", user_id: "user_id"})
113
+ }.not_to raise_error
114
+ end
115
+
116
+ it 'expect client to return nil when calling with a non-hash identity' do
117
+ expect { @instance.send_verification_email('user_id', identity: "nonhash") }.to raise_error(
118
+ 'Identity must be a hash send an email verification'
119
+ )
120
+ end
121
+
105
122
  it 'should raise an error if the user_id is empty' do
106
123
  expect do
107
124
  @instance.send_verification_email('')
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+ describe Auth0::Api::V2::LogStreams do
3
+ before :all do
4
+ dummy_instance = DummyClass.new
5
+ dummy_instance.extend(Auth0::Api::V2::LogStreams)
6
+ dummy_instance.extend(Auth0::Mixins::Initializer)
7
+ @instance = dummy_instance
8
+ end
9
+
10
+ context '.log_streams' do
11
+ it { expect(@instance).to respond_to(:log_streams) }
12
+ it { expect(@instance).to respond_to(:get_log_streams) }
13
+ it 'is expected to call get /api/v2/log-streams' do
14
+ expect(@instance).to receive(:get).with(
15
+ '/api/v2/log-streams'
16
+ )
17
+ expect { @instance.log_streams }.not_to raise_error
18
+ end
19
+ end
20
+
21
+ context '.log_stream' do
22
+ it { expect(@instance).to respond_to(:log_stream) }
23
+ it 'is expected to call get /api/v2/log-streams/test' do
24
+ expect(@instance).to receive(:get).with('/api/v2/log-streams/test')
25
+ expect { @instance.log_stream('test') }.not_to raise_error
26
+ end
27
+ it 'expect to raise an error when calling with empty log stream id' do
28
+ expect { @instance.log_stream(nil) }.to raise_error 'Must supply a valid log stream id'
29
+ end
30
+ end
31
+
32
+ context '.create_log_stream' do
33
+ it { expect(@instance).to respond_to(:create_log_stream) }
34
+ it 'is expected to call post /api/v2/log-streams' do
35
+ expect(@instance).to receive(:post).with(
36
+ '/api/v2/log-streams',
37
+ name: 'test',
38
+ type: 'https',
39
+ sink: {
40
+ httpEndpoint: "https://mycompany.com",
41
+ httpContentType: "string",
42
+ httpContentFormat: "JSONLINES",
43
+ httpAuthorization: "string"
44
+ }
45
+ )
46
+
47
+ @instance.create_log_stream('test', 'https',
48
+ httpEndpoint: "https://mycompany.com",
49
+ httpContentType: "string",
50
+ httpContentFormat: "JSONLINES",
51
+ httpAuthorization: "string")
52
+ end
53
+ it 'expect to raise an error when calling with empty name' do
54
+ expect { @instance.create_log_stream('', '', '') }.to raise_error 'Name must contain at least one character'
55
+ end
56
+ it 'expect to raise an error when calling with empty type' do
57
+ expect { @instance.create_log_stream('name', '', '') }.to raise_error 'Must specify a valid type'
58
+ end
59
+ it 'expect to raise an error when calling without options' do
60
+ expect { @instance.create_log_stream('name', 'https', nil) }.to raise_error 'Must supply a valid hash for options'
61
+ end
62
+ end
63
+
64
+ context '.delete_log_stream' do
65
+ it { expect(@instance).to respond_to(:delete_log_stream) }
66
+ it 'is expected to call delete /api/v2/log-streams/test' do
67
+ expect(@instance).to receive(:delete).with('/api/v2/log-streams/test')
68
+ expect { @instance.delete_log_stream('test') }.not_to raise_error
69
+ end
70
+ it 'expect to raise an error when calling with empty log stream id' do
71
+ expect { @instance.delete_log_stream(nil) }.to raise_error 'Must supply a valid log stream id'
72
+ end
73
+ end
74
+
75
+ context '.patch_log_stream' do
76
+ it { expect(@instance).to respond_to(:patch_log_stream) }
77
+ it 'is expected to send patch to /api/v2/log_streams/test' do
78
+ expect(@instance).to receive(:patch).with('/api/v2/log-streams/test', status: 'paused')
79
+ expect { @instance.patch_log_stream('test', 'paused') }.not_to raise_error
80
+ end
81
+ it { expect { @instance.patch_log_stream('', nil) }.to raise_error 'Must specify a log stream id' }
82
+ it { expect { @instance.patch_log_stream('test', nil) }.to raise_error 'Must specify a valid status' }
83
+ end
84
+ end