Module: DeviseScim::RSpec::ScimHelpers

Defined in:
lib/devise_scim/rspec/scim_helpers.rb

Instance Method Summary collapse

Instance Method Details

#scim_add_op(path, value) ⇒ Object



34
35
36
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 34

def scim_add_op(path, value)
  { "op" => "add", "path" => path, "value" => value }
end

#scim_auth_headers(token) ⇒ Object



14
15
16
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 14

def scim_auth_headers(token)
  { "Authorization" => "Bearer #{token}", "Content-Type" => "application/json" }
end

#scim_json(body) ⇒ Object



6
7
8
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 6

def scim_json(body)
  JSON.parse(body)
end

#scim_patch_payload(*operations) ⇒ Object



23
24
25
26
27
28
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 23

def scim_patch_payload(*operations)
  {
    "schemas" => ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
    "Operations" => operations
  }
end

#scim_prefixObject



10
11
12
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 10

def scim_prefix
  DeviseScim.configuration.route_prefix
end

#scim_remove_op(path) ⇒ Object



38
39
40
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 38

def scim_remove_op(path)
  { "op" => "remove", "path" => path }
end

#scim_replace_op(path, value) ⇒ Object



30
31
32
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 30

def scim_replace_op(path, value)
  { "op" => "replace", "path" => path, "value" => value }
end

#scim_user_payload(user_name:, **attrs) ⇒ Object



18
19
20
21
# File 'lib/devise_scim/rspec/scim_helpers.rb', line 18

def scim_user_payload(user_name:, **attrs)
  base = { "schemas" => [DeviseScim::Scim::USER_SCHEMA], "userName" => user_name }
  base.merge(attrs.transform_keys(&:to_s))
end