Skip to content

Commit a49a1e6

Browse files
authored
Merge pull request #5 from bugcrowd/profile-mapping
Add support for list/get/update profile mappings
2 parents 9a19694 + 759b40c commit a49a1e6

File tree

7 files changed

+305
-0
lines changed

7 files changed

+305
-0
lines changed

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ GEM
8383
PLATFORMS
8484
-darwin-21
8585
arm64-darwin-21
86+
arm64-darwin-22
8687
arm64-darwin-24
8788
x86_64-linux
8889

lib/oktakit/client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
require 'oktakit/client/identity_providers'
1010
require 'oktakit/client/policies'
1111
require 'oktakit/client/policy_rules'
12+
require 'oktakit/client/profile_mappings'
1213
require 'oktakit/client/schemas'
1314
require 'oktakit/client/templates'
1415
require 'oktakit/client/users'
@@ -24,6 +25,7 @@ class Client
2425
include IdentityProviders
2526
include Policies
2627
include PolicyRules
28+
include ProfileMappings
2729
include Schemas
2830
include Templates
2931
include Users
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module Oktakit
2+
class Client
3+
module ProfileMappings
4+
# List ProfileMappings
5+
#
6+
# @param options[:query] [Hash] Optional. Query params for request
7+
# @param options[:headers] [Hash] Optional. Header params for the request.
8+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
9+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
10+
# @param options [Hash] Optional. Body params for request.
11+
# @return [Array<Sawyer::Resource>] Array of ProfileMappings
12+
# @see https://developer.okta.com/docs/api/openapi/okta-management/management/tag/ProfileMapping/#tag/ProfileMapping/operation/listProfileMappings
13+
# @example
14+
# Oktakit.list_profile_mappings(query: {type: 'IDP_DISCOVERY'})
15+
def list_profile_mappings(options = {})
16+
get("/mappings", options)
17+
end
18+
19+
# Retrieve a profile_mapping
20+
#
21+
# @param options[:query] [Hash] Optional. Query params for request
22+
# @param options[:headers] [Hash] Optional. Header params for the request.
23+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
24+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
25+
# @param options [Hash] Optional. Body params for request.
26+
# @return [Sawyer::Resource] ProfileMapping
27+
# @see https://developer.okta.com/docs/api/openapi/okta-management/management/tag/ProfileMapping/#tag/ProfileMapping/operation/getProfileMapping
28+
# @example
29+
# Oktakit.get_profile_mapping('id')
30+
def get_profile_mapping(id, options = {})
31+
get("/mappings/#{id}", options)
32+
end
33+
34+
# Update a profile_mapping
35+
#
36+
# @param options[:query] [Hash] Optional. Query params for request
37+
# @param options[:headers] [Hash] Optional. Header params for the request.
38+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
39+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
40+
# @param options [Hash] Optional. Body params for request.
41+
# @return [Sawyer::Resource] The updated ProfileMapping
42+
# @see https://developer.okta.com/docs/api/openapi/okta-management/management/tag/ProfileMapping/#tag/ProfileMapping/operation/replaceProfileMapping
43+
# @example
44+
# Oktakit.update_profile_mapping('id', options)
45+
def update_profile_mapping(id, options = {})
46+
post("/mappings/#{id}", options)
47+
end
48+
end
49+
end
50+
end

spec/cassettes/get_profile_mapping.yml

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/cassettes/list_profile_mappings.yml

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/cassettes/update_profile_mapping.yml

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require "spec_helper"
2+
3+
describe Oktakit::Client::ProfileMappings do
4+
PROFILE_MAPPING_ID = "aprofilemappingid"
5+
PROFILE_MAPPING_SOURCE_ID = "aprofilesourceid"
6+
7+
describe "#list_profile_mappings" do
8+
it "returns array of profile_mappings" do
9+
VCR.use_cassette("list_profile_mappings") do
10+
resp, = client.list_profile_mappings(query: { sourceId: PROFILE_MAPPING_SOURCE_ID })
11+
expect(resp).to(be_a(Array))
12+
end
13+
end
14+
end
15+
16+
describe "#get_profile_mapping" do
17+
it "returns the fetched profile_mapping." do
18+
VCR.use_cassette("get_profile_mapping") do
19+
resp, = client.get_profile_mapping(PROFILE_MAPPING_ID)
20+
expect(resp.id).not_to(be_nil)
21+
expect(resp.id).to(be == PROFILE_MAPPING_ID)
22+
end
23+
end
24+
end
25+
26+
describe "#update_profile_mapping" do
27+
it "returns the updated profile_mapping." do
28+
VCR.use_cassette("update_profile_mapping") do
29+
resp, = client.update_profile_mapping(
30+
PROFILE_MAPPING_ID,
31+
"properties": { "email": {
32+
"expression": "appuser.subjectNameId",
33+
"pushStatus": "DONT_PUSH",
34+
} }
35+
)
36+
expect(resp.id).not_to(be_nil)
37+
end
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)