From eb10e2d0a2e9178cc545dee8721737e03f88fc37 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 24 Nov 2020 17:29:13 -0500 Subject: [PATCH] Add App User Schema operations --- lib/oktakit/client/schemas.rb | 64 ++++++++++++ ...dd_property_to_app_user_profile_schema.yml | 89 +++++++++++++++++ spec/cassettes/get_app_user_schema.yml | 90 +++++++++++++++++ ..._property_from_app_user_profile_schema.yml | 87 ++++++++++++++++ ...pdate_app_user_profile_schema_property.yml | 89 +++++++++++++++++ spec/client/schemas_spec.rb | 99 ++++++++++++++++++- 6 files changed, 517 insertions(+), 1 deletion(-) create mode 100644 spec/cassettes/add_property_to_app_user_profile_schema.yml create mode 100644 spec/cassettes/get_app_user_schema.yml create mode 100644 spec/cassettes/remove_property_from_app_user_profile_schema.yml create mode 100644 spec/cassettes/update_app_user_profile_schema_property.yml diff --git a/lib/oktakit/client/schemas.rb b/lib/oktakit/client/schemas.rb index d630e3d..2e6003d 100644 --- a/lib/oktakit/client/schemas.rb +++ b/lib/oktakit/client/schemas.rb @@ -60,6 +60,70 @@ def update_user_profile_schema_property(options = {}) def remove_property_from_user_profile_schema(options = {}) post('/meta/schemas/user/default', options) end + + # Get App User Schema + # + # @params id [string] Application ID + # @param options[:query] [Hash] Optional. Query params for request + # @param options[:headers] [Hash] Optional. Header params for the request. + # @param options[:accept] [String] Optional. The content type to accept. Default application/json + # @param options[:content_type] [String] Optional. The content type for the request. Default application/json + # @param options [Hash] Optional. Body params for request. + # @return [Hash] User Schema + # @see https://developer.okta.com/docs/reference/api/schemas/#get-app-user-schema + # @example + # Oktakit.get_app_user_schema('id') + def get_app_user_schema(id, options = {}) + get("/meta/schemas/apps/#{id}/default", options) + end + + # Add Property to App User Profile Schema + # + # @params id [string] Application ID + # @param options[:query] [Hash] Optional. Query params for request + # @param options[:headers] [Hash] Optional. Header params for the request. + # @param options[:accept] [String] Optional. The content type to accept. Default application/json + # @param options[:content_type] [String] Optional. The content type for the request. Default application/json + # @param options [Hash] Optional. Body params for request. + # @return [Hash] User Schema + # @see https://developer.okta.com/docs/reference/api/schemas/#add-property-to-app-user-profile-schema + # @example + # Oktakit.add_property_to_app_user_profile_schema('id') + def add_property_to_app_user_profile_schema(id, options = {}) + post("/meta/schemas/apps/#{id}/default", options) + end + + # Update App User Profile Schema property + # + # @params id [string] Application ID + # @param options[:query] [Hash] Optional. Query params for request + # @param options[:headers] [Hash] Optional. Header params for the request. + # @param options[:accept] [String] Optional. The content type to accept. Default application/json + # @param options[:content_type] [String] Optional. The content type for the request. Default application/json + # @param options [Hash] Optional. Body params for request. + # @return [Hash] User Schema + # @see https://developer.okta.com/docs/reference/api/schemas/#update-app-user-profile-schema-property + # @example + # Oktakit.update_app_user_profile_schema_property('id') + def update_app_user_profile_schema_property(id, options = {}) + post("/meta/schemas/apps/#{id}/default", options) + end + + # Remove property from App User Profile Schema + # + # @params id [string] Application ID + # @param options[:query] [Hash] Optional. Query params for request + # @param options[:headers] [Hash] Optional. Header params for the request. + # @param options[:accept] [String] Optional. The content type to accept. Default application/json + # @param options[:content_type] [String] Optional. The content type for the request. Default application/json + # @param options [Hash] Optional. Body params for request. + # @return [Hash] User Schema + # @see https://developer.okta.com/docs/reference/api/schemas/#remove-property-from-app-user-profile-schema + # @example + # Oktakit.remove_property_from_app_user_profile_schema('id') + def remove_property_from_app_user_profile_schema(id, options = {}) + post("/meta/schemas/apps/#{id}/default", options) + end end end end diff --git a/spec/cassettes/add_property_to_app_user_profile_schema.yml b/spec/cassettes/add_property_to_app_user_profile_schema.yml new file mode 100644 index 0000000..a3f5a9f --- /dev/null +++ b/spec/cassettes/add_property_to_app_user_profile_schema.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: post + uri: https://okta-test.okta.com/api/v1/meta/schemas/apps/okta-test-application/default + body: + encoding: UTF-8 + string: '{"definitions":{"custom":{"id":"#custom","type":"object","properties":{"twitterUserName":{"title":"Twitter + username","description":"User''s username for twitter.com","type":"string","required":false,"minLength":1,"maxLength":20,"permissions":[{"principal":"SELF","action":"READ_WRITE"}]}},"required":[]}}}' + headers: + User-Agent: + - Oktakit v0.2.0 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS <> + response: + status: + code: 200 + message: + headers: + date: + - Tue, 24 Nov 2020 22:18:48 GMT + content-type: + - application/json;charset=UTF-8 + transfer-encoding: + - chunked + connection: + - keep-alive + server: + - nginx + vary: + - Accept-Encoding + x-okta-request-id: + - X72GyG1WrZbH7bhvTYBHVwAADW4 + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '1000' + x-rate-limit-remaining: + - '997' + x-rate-limit-reset: + - '1606256351' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + x-content-type-options: + - nosniff + strict-transport-security: + - max-age=315360000; includeSubDomains + set-cookie: + - sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=C1329F1A3A486A25DA2FE86573BF7AA1; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '{"id":"https://okta-test.okta.com/meta/schemas/apps/okta-test-application/default","$schema":"http://json-schema.org/draft-04/schema#","name":"oidc_client_31337","title":" + Experiments User","lastUpdated":"2020-11-24T22:18:48.000Z","created":"2020-11-23T18:24:26.000Z","definitions":{"custom":{"id":"#custom","type":"object","properties":{"twitterUserName":{"title":"Twitter + username","description":"User''s username for twitter.com","type":"string","scope":"NONE","minLength":1,"maxLength":20,"master":{"type":"PROFILE_MASTER"}}},"required":[]},"base":{"id":"#base","type":"object","properties":{"userName":{"title":"Username","type":"string","required":true,"externalName":"preferred_username","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"name":{"title":"Name","description":"End-User''s + full name in displayable form.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"nickname":{"title":"Nickname","description":"Casual + name of the End-User (may or may not be the same as the given_name)","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"given_name":{"title":"Given + Name","description":"Given name or first name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"middle_name":{"title":"Middle + Name","description":"Middle name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"family_name":{"title":"Family + Name","description":"Surname or last name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"email":{"title":"Email","description":"End-User''s + preferred e-mail address.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"profile":{"title":"Profile + URL","description":"URL of the End-User''s profile page.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"picture":{"title":"Picture + URL","description":"URL of the End-User''s profile picture.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"website":{"title":"Website","description":"URL + of the End-User''s Web page or blog.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"gender":{"title":"Gender","description":"End-User''s + gender.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"birthdate":{"title":"Birthdate","description":"End-User''s + birthday, represented as an ISO 8601:2004 YYYY-MM-DD format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"zoneinfo":{"title":"Time + Zone","description":"String representing the End-User''s time zone.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locale":{"title":"Locale + Name","description":"ISO3166‑1 country code in uppercase, separated by a dash + (e.g. ''en-US'')","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"phone_number":{"title":"Phone + Number","description":"End-User''s preferred telephone number in E.164 format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"street_address":{"title":"Street + Address","description":"Full street address component.","type":"string","externalName":"address.street_address","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locality":{"title":"Locality","description":"City + or locality component.","type":"string","externalName":"address.locality","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"region":{"title":"Region","description":"State, + province, prefecture, or region component.","type":"string","externalName":"address.region","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"postal_code":{"title":"Postal + Code","description":"Zip code or postal code component.","type":"string","externalName":"address.postal_code","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"country":{"title":"Country","description":"Country + name component.","type":"string","externalName":"address.country","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"formatted":{"title":"Formatted","description":"Full + mailing address, formatted for display.","type":"string","externalName":"address.formatted","scope":"SELF","master":{"type":"PROFILE_MASTER"}}},"required":["userName"]}},"type":"object","properties":{"profile":{"allOf":[{"$ref":"#/definitions/custom"},{"$ref":"#/definitions/base"}]}}}' + http_version: + recorded_at: Tue, 24 Nov 2020 22:18:48 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/get_app_user_schema.yml b/spec/cassettes/get_app_user_schema.yml new file mode 100644 index 0000000..eaf69f5 --- /dev/null +++ b/spec/cassettes/get_app_user_schema.yml @@ -0,0 +1,90 @@ +--- +http_interactions: +- request: + method: get + uri: https://okta-test.okta.com/api/v1/meta/schemas/apps/okta-test-application/default + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Oktakit v0.2.0 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS <> + response: + status: + code: 200 + message: + headers: + date: + - Tue, 24 Nov 2020 21:55:37 GMT + content-type: + - application/json;charset=UTF-8 + transfer-encoding: + - chunked + connection: + - keep-alive + server: + - nginx + vary: + - Accept-Encoding + x-okta-request-id: + - X72BWQNzlThSGCKP8vbpxQAAEgA + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '1000' + x-rate-limit-remaining: + - '999' + x-rate-limit-reset: + - '1606254997' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + x-content-type-options: + - nosniff + strict-transport-security: + - max-age=315360000; includeSubDomains + set-cookie: + - sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=085ED06A2D7128B209FDD2D407DD54E9; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '{"id":"https://okta-test.okta.com/meta/schemas/apps/okta-test-application/default","$schema":"http://json-schema.org/draft-04/schema#","name":"oidc_client","title":"Auth + @ Development User","lastUpdated":"2020-11-15T21:08:48.000Z","created":"2020-09-09T19:21:24.000Z","definitions":{"custom":{"id":"#custom","type":"object","properties":{"regional_ops_admin":{"title":"Regional + Ops Admin","description":"Regional Ops Admin and corresponding scoped regions","type":"array","scope":"NONE","items":{"type":"string"},"union":"DISABLE","master":{"type":"PROFILE_MASTER"}},"global_ops_admin":{"title":"Global + Ops Admin","description":"Headquarter employees who manage cross-region concerns + such as setting up new regional admin, phone blacklist etc.","type":"boolean","scope":"NONE","master":{"type":"PROFILE_MASTER"}}},"required":[]},"base":{"id":"#base","type":"object","properties":{"userName":{"title":"Username","type":"string","required":true,"externalName":"preferred_username","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"name":{"title":"Name","description":"End-User''s + full name in displayable form.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"nickname":{"title":"Nickname","description":"Casual + name of the End-User (may or may not be the same as the given_name)","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"given_name":{"title":"Given + Name","description":"Given name or first name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"middle_name":{"title":"Middle + Name","description":"Middle name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"family_name":{"title":"Family + Name","description":"Surname or last name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"email":{"title":"Email","description":"End-User''s + preferred e-mail address.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"profile":{"title":"Profile + URL","description":"URL of the End-User''s profile page.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"picture":{"title":"Picture + URL","description":"URL of the End-User''s profile picture.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"website":{"title":"Website","description":"URL + of the End-User''s Web page or blog.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"gender":{"title":"Gender","description":"End-User''s + gender.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"birthdate":{"title":"Birthdate","description":"End-User''s + birthday, represented as an ISO 8601:2004 YYYY-MM-DD format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"zoneinfo":{"title":"Time + Zone","description":"String representing the End-User''s time zone.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locale":{"title":"Locale + Name","description":"ISO3166‑1 country code in uppercase, separated by a dash + (e.g. ''en-US'')","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"phone_number":{"title":"Phone + Number","description":"End-User''s preferred telephone number in E.164 format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"street_address":{"title":"Street + Address","description":"Full street address component.","type":"string","externalName":"address.street_address","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locality":{"title":"Locality","description":"City + or locality component.","type":"string","externalName":"address.locality","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"region":{"title":"Region","description":"State, + province, prefecture, or region component.","type":"string","externalName":"address.region","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"postal_code":{"title":"Postal + Code","description":"Zip code or postal code component.","type":"string","externalName":"address.postal_code","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"country":{"title":"Country","description":"Country + name component.","type":"string","externalName":"address.country","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"formatted":{"title":"Formatted","description":"Full + mailing address, formatted for display.","type":"string","externalName":"address.formatted","scope":"SELF","master":{"type":"PROFILE_MASTER"}}},"required":["userName"]}},"type":"object","properties":{"profile":{"allOf":[{"$ref":"#/definitions/custom"},{"$ref":"#/definitions/base"}]}}}' + http_version: + recorded_at: Tue, 24 Nov 2020 21:55:37 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/remove_property_from_app_user_profile_schema.yml b/spec/cassettes/remove_property_from_app_user_profile_schema.yml new file mode 100644 index 0000000..07ba1eb --- /dev/null +++ b/spec/cassettes/remove_property_from_app_user_profile_schema.yml @@ -0,0 +1,87 @@ +--- +http_interactions: +- request: + method: post + uri: https://okta-test.okta.com/api/v1/meta/schemas/apps/okta-test-application/default + body: + encoding: UTF-8 + string: '{"definitions":{"custom":{"id":"#custom","type":"object","properties":{"twitterUserName":null}}}}' + headers: + User-Agent: + - Oktakit v0.2.0 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS <> + response: + status: + code: 200 + message: + headers: + date: + - Tue, 24 Nov 2020 22:25:15 GMT + content-type: + - application/json;charset=UTF-8 + transfer-encoding: + - chunked + connection: + - keep-alive + server: + - nginx + vary: + - Accept-Encoding + x-okta-request-id: + - X72ISybd5Fa7feeg06S-LgAACwM + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '1000' + x-rate-limit-remaining: + - '999' + x-rate-limit-reset: + - '1606256775' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + x-content-type-options: + - nosniff + strict-transport-security: + - max-age=315360000; includeSubDomains + set-cookie: + - sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=A48A6EA443087F21FE04400A15D00F2B; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '{"id":"https://okta-test.okta.com/meta/schemas/apps/okta-test-application/default","$schema":"http://json-schema.org/draft-04/schema#","name":"oidc_client_31337","title":" + Experiments User","lastUpdated":"2020-11-24T22:25:15.000Z","created":"2020-11-23T18:24:26.000Z","definitions":{"custom":{"id":"#custom","type":"object","properties":{}},"base":{"id":"#base","type":"object","properties":{"userName":{"title":"Username","type":"string","required":true,"externalName":"preferred_username","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"name":{"title":"Name","description":"End-User''s + full name in displayable form.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"nickname":{"title":"Nickname","description":"Casual + name of the End-User (may or may not be the same as the given_name)","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"given_name":{"title":"Given + Name","description":"Given name or first name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"middle_name":{"title":"Middle + Name","description":"Middle name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"family_name":{"title":"Family + Name","description":"Surname or last name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"email":{"title":"Email","description":"End-User''s + preferred e-mail address.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"profile":{"title":"Profile + URL","description":"URL of the End-User''s profile page.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"picture":{"title":"Picture + URL","description":"URL of the End-User''s profile picture.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"website":{"title":"Website","description":"URL + of the End-User''s Web page or blog.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"gender":{"title":"Gender","description":"End-User''s + gender.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"birthdate":{"title":"Birthdate","description":"End-User''s + birthday, represented as an ISO 8601:2004 YYYY-MM-DD format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"zoneinfo":{"title":"Time + Zone","description":"String representing the End-User''s time zone.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locale":{"title":"Locale + Name","description":"ISO3166‑1 country code in uppercase, separated by a dash + (e.g. ''en-US'')","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"phone_number":{"title":"Phone + Number","description":"End-User''s preferred telephone number in E.164 format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"street_address":{"title":"Street + Address","description":"Full street address component.","type":"string","externalName":"address.street_address","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locality":{"title":"Locality","description":"City + or locality component.","type":"string","externalName":"address.locality","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"region":{"title":"Region","description":"State, + province, prefecture, or region component.","type":"string","externalName":"address.region","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"postal_code":{"title":"Postal + Code","description":"Zip code or postal code component.","type":"string","externalName":"address.postal_code","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"country":{"title":"Country","description":"Country + name component.","type":"string","externalName":"address.country","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"formatted":{"title":"Formatted","description":"Full + mailing address, formatted for display.","type":"string","externalName":"address.formatted","scope":"SELF","master":{"type":"PROFILE_MASTER"}}},"required":["userName"]}},"type":"object","properties":{"profile":{"allOf":[{"$ref":"#/definitions/custom"},{"$ref":"#/definitions/base"}]}}}' + http_version: + recorded_at: Tue, 24 Nov 2020 22:25:15 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/update_app_user_profile_schema_property.yml b/spec/cassettes/update_app_user_profile_schema_property.yml new file mode 100644 index 0000000..d5090eb --- /dev/null +++ b/spec/cassettes/update_app_user_profile_schema_property.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: post + uri: https://okta-test.okta.com/api/v1/meta/schemas/apps/okta-test-application/default + body: + encoding: UTF-8 + string: '{"definitions":{"custom":{"id":"#custom","type":"object","properties":{"twitterUserName":{"title":"Twitter + username","description":"User''s username for twitter.com","type":"string","required":false,"minLength":1,"maxLength":10,"permissions":[{"principal":"SELF","action":"READ_ONLY"}]}},"required":[]}}}' + headers: + User-Agent: + - Oktakit v0.2.0 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS <> + response: + status: + code: 200 + message: + headers: + date: + - Tue, 24 Nov 2020 22:24:13 GMT + content-type: + - application/json;charset=UTF-8 + transfer-encoding: + - chunked + connection: + - keep-alive + server: + - nginx + vary: + - Accept-Encoding + x-okta-request-id: + - X72IDTfdpSzBZS2c8xmcowAADtg + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '1000' + x-rate-limit-remaining: + - '998' + x-rate-limit-reset: + - '1606256658' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + x-content-type-options: + - nosniff + strict-transport-security: + - max-age=315360000; includeSubDomains + set-cookie: + - sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=A629547A13A584C6097C3A7659F99970; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '{"id":"https://okta-test.okta.com/meta/schemas/apps/okta-test-application/default","$schema":"http://json-schema.org/draft-04/schema#","name":"oidc_client_31337","title":" + Experiments User","lastUpdated":"2020-11-24T22:24:13.000Z","created":"2020-11-23T18:24:26.000Z","definitions":{"custom":{"id":"#custom","type":"object","properties":{"twitterUserName":{"title":"Twitter + username","description":"User''s username for twitter.com","type":"string","scope":"NONE","minLength":1,"maxLength":10,"master":{"type":"PROFILE_MASTER"}}},"required":[]},"base":{"id":"#base","type":"object","properties":{"userName":{"title":"Username","type":"string","required":true,"externalName":"preferred_username","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"name":{"title":"Name","description":"End-User''s + full name in displayable form.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"nickname":{"title":"Nickname","description":"Casual + name of the End-User (may or may not be the same as the given_name)","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"given_name":{"title":"Given + Name","description":"Given name or first name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"middle_name":{"title":"Middle + Name","description":"Middle name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"family_name":{"title":"Family + Name","description":"Surname or last name of the End-User.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"email":{"title":"Email","description":"End-User''s + preferred e-mail address.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"profile":{"title":"Profile + URL","description":"URL of the End-User''s profile page.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"picture":{"title":"Picture + URL","description":"URL of the End-User''s profile picture.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"website":{"title":"Website","description":"URL + of the End-User''s Web page or blog.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"gender":{"title":"Gender","description":"End-User''s + gender.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"birthdate":{"title":"Birthdate","description":"End-User''s + birthday, represented as an ISO 8601:2004 YYYY-MM-DD format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"zoneinfo":{"title":"Time + Zone","description":"String representing the End-User''s time zone.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locale":{"title":"Locale + Name","description":"ISO3166‑1 country code in uppercase, separated by a dash + (e.g. ''en-US'')","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"phone_number":{"title":"Phone + Number","description":"End-User''s preferred telephone number in E.164 format.","type":"string","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"street_address":{"title":"Street + Address","description":"Full street address component.","type":"string","externalName":"address.street_address","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"locality":{"title":"Locality","description":"City + or locality component.","type":"string","externalName":"address.locality","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"region":{"title":"Region","description":"State, + province, prefecture, or region component.","type":"string","externalName":"address.region","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"postal_code":{"title":"Postal + Code","description":"Zip code or postal code component.","type":"string","externalName":"address.postal_code","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"country":{"title":"Country","description":"Country + name component.","type":"string","externalName":"address.country","scope":"SELF","master":{"type":"PROFILE_MASTER"}},"formatted":{"title":"Formatted","description":"Full + mailing address, formatted for display.","type":"string","externalName":"address.formatted","scope":"SELF","master":{"type":"PROFILE_MASTER"}}},"required":["userName"]}},"type":"object","properties":{"profile":{"allOf":[{"$ref":"#/definitions/custom"},{"$ref":"#/definitions/base"}]}}}' + http_version: + recorded_at: Tue, 24 Nov 2020 22:24:13 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/client/schemas_spec.rb b/spec/client/schemas_spec.rb index e29f0bd..a3a6044 100644 --- a/spec/client/schemas_spec.rb +++ b/spec/client/schemas_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Oktakit::Client::Schemas do - SCHEMAS_SCHEMA_ID = 'https://okta-test.okta.com/meta/schemas/user/default' + let(:app_id) { 'okta-test-application' } describe '#get_user_schema' do it 'returns user schema' do @@ -96,4 +96,101 @@ end end end + + describe '#get_app_user_schema' do + it 'returns user schema' do + VCR.use_cassette('get_app_user_schema') do + resp, = client.get_app_user_schema(app_id) + expect(resp.id).not_to(be_nil) + end + end + end + + describe '#add_property_to_app_user_profile_schema' do + it 'returns user schema' do + VCR.use_cassette('add_property_to_app_user_profile_schema') do + resp, status = client.add_property_to_app_user_profile_schema( + app_id, + definitions: { + custom: { + id: "#custom", + type: "object", + properties: { + twitterUserName: { + title: "Twitter username", + description: "User's username for twitter.com", + type: "string", + required: false, + minLength: 1, + maxLength: 20, + permissions: [ + { + principal: "SELF", + action: "READ_WRITE", + }, + ], + }, + }, + required: [], + }, + } + ) + expect(resp.id).not_to(be_nil) + expect(status).to(be(200)) + end + end + end + + describe '#update_app_user_profile_schema_property' do + it 'returns user schema' do + VCR.use_cassette('update_app_user_profile_schema_property') do + resp, status = client.update_app_user_profile_schema_property( + app_id, + definitions: { + custom: { + id: "#custom", + type: "object", + properties: { + twitterUserName: { + title: "Twitter username", + description: "User's username for twitter.com", + type: "string", + required: false, + minLength: 1, + maxLength: 10, + permissions: [ + { + principal: "SELF", + action: "READ_ONLY", + }, + ], + }, + }, + required: [], + }, + } + ) + expect(resp.id).not_to(be_nil) + expect(status).to(be(200)) + end + end + end + + describe '#remove_property_from_app_user_profile_schema' do + it 'returns user schema' do + VCR.use_cassette('remove_property_from_app_user_profile_schema') do + _, status = client.remove_property_from_app_user_profile_schema( + app_id, + definitions: { + custom: { + id: "#custom", + type: "object", + properties: { twitterUserName: nil }, + }, + } + ) + expect(status).to(be(200)) + end + end + end end