diff --git a/lib/oktakit/client/users.rb b/lib/oktakit/client/users.rb index 74aae5f..c4512d4 100644 --- a/lib/oktakit/client/users.rb +++ b/lib/oktakit/client/users.rb @@ -131,6 +131,24 @@ def activate_user(id, options = {}) post("/users/#{id}/lifecycle/activate", options) end + # Reactivate User + # + # @params id [string] User 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]. + # @note The user must be in a PROVISIONED status + # @see https://developer.okta.com/docs/reference/api/users/#reactivate-user + # @example + # Oktakit.reactivate_user('id') + + def reactivate_user(id, options = {}) + post("/users/#{id}/lifecycle/reactivate", options) + end + # Deactivate User # # @params id [string] User ID @@ -147,6 +165,24 @@ def deactivate_user(id, options = {}) post("/users/#{id}/lifecycle/deactivate", options) end + # Delete User + # + # @params id [string] User 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 the request. + # @return 204 'No Content' + # @note Deletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status. This action cannot be recovered! + # This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user. + # @see https://developer.okta.com/docs/reference/api/users/#delete-user + # @example + # Oktakit.delete_user('id') + def delete_user(id, options = {}) + delete("/users/#{id}", options) + end + # Suspend User # # @params id [string] User ID diff --git a/spec/cassettes/delete_user.yml b/spec/cassettes/delete_user.yml new file mode 100644 index 0000000..06a1f22 --- /dev/null +++ b/spec/cassettes/delete_user.yml @@ -0,0 +1,65 @@ +--- +http_interactions: +- request: + method: delete + uri: https://okta-test.okta.com/api/v1/users/00u6o0w6tyuPVEeZr0h7 + body: + encoding: UTF-8 + string: "{}" + headers: + User-Agent: + - Oktakit v0.2.1 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS 00AmrrD0Mvd5eVIzaP6wr9BsDDFOUu61zWytQ2yf5o + response: + status: + code: 204 + message: + headers: + date: + - Mon, 22 Nov 2021 18:28:44 GMT + connection: + - keep-alive + server: + - nginx + public-key-pins-report-only: + - pin-sha256="jZomPEBSDXoipA9un78hKRIeN/+U4ZteRaiX8YpWfqc="; pin-sha256="axSbM6RQ+19oXxudaOTdwXJbSr6f7AahxbDHFy3p8s8="; + pin-sha256="SE4qe2vdD9tAegPwO79rMnZyhHvqj3i5g1c2HkyGUNE="; pin-sha256="ylP0lMLMvBaiHn0ihLxHjzvlPVQNoyQ+rMiaj0da/Pw="; + max-age=60; report-uri="https://okta.report-uri.com/r/default/hpkp/reportOnly" + x-okta-request-id: + - YZvhXNDEXRFjP5tqu8tyYwAADP4 + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '600' + x-rate-limit-remaining: + - '599' + x-rate-limit-reset: + - '1637605784' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + expect-ct: + - report-uri="https://oktaexpectct.report-uri.com/r/t/ct/reportOnly", max-age=0 + x-frame-options: + - SAMEORIGIN + strict-transport-security: + - max-age=315360000; includeSubDomains + set-cookie: + - sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=71EBF44305F41332FD492D6DF26BB174; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '' + http_version: + recorded_at: Mon, 22 Nov 2021 18:28:44 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/reactivate_user.yml b/spec/cassettes/reactivate_user.yml new file mode 100644 index 0000000..146e279 --- /dev/null +++ b/spec/cassettes/reactivate_user.yml @@ -0,0 +1,71 @@ +--- +http_interactions: +- request: + method: post + uri: https://okta-test.okta.com/api/v1/users/00u6o0w6tyuPVEeZr0h7/lifecycle/reactivate + body: + encoding: UTF-8 + string: "{}" + headers: + User-Agent: + - Oktakit v0.2.1 + Accept: + - application/json + Content-Type: + - application/json + Authorization: + - SSWS 00AmrrD0Mvd5eVIzaP6wr9BsDDFOUu61zWytQ2yf5o + response: + status: + code: 200 + message: + headers: + date: + - Mon, 22 Nov 2021 15:41:34 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + server: + - nginx + public-key-pins-report-only: + - pin-sha256="jZomPEBSDXoipA9un78hKRIeN/+U4ZteRaiX8YpWfqc="; pin-sha256="axSbM6RQ+19oXxudaOTdwXJbSr6f7AahxbDHFy3p8s8="; + pin-sha256="SE4qe2vdD9tAegPwO79rMnZyhHvqj3i5g1c2HkyGUNE="; pin-sha256="ylP0lMLMvBaiHn0ihLxHjzvlPVQNoyQ+rMiaj0da/Pw="; + max-age=60; report-uri="https://okta.report-uri.com/r/default/hpkp/reportOnly" + vary: + - Accept-Encoding + x-okta-request-id: + - YZu6LeHdLZlyG1fg5pfS@AAAA44 + x-xss-protection: + - '0' + p3p: + - CP="HONK" + x-rate-limit-limit: + - '600' + x-rate-limit-remaining: + - '599' + x-rate-limit-reset: + - '1637595753' + cache-control: + - no-cache, no-store + pragma: + - no-cache + expires: + - '0' + expect-ct: + - report-uri="https://oktaexpectct.report-uri.com/r/t/ct/reportOnly", max-age=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=D47AF9D36773B7390C6E69915A514E7D; + Path=/; Secure; HttpOnly + body: + encoding: UTF-8 + string: '{"activationToken":"-9OhPWRjr7_S8t2iV5_w"}' + http_version: + recorded_at: Mon, 22 Nov 2021 15:41:34 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/client/users_spec.rb b/spec/client/users_spec.rb index 2f0716e..a936d3a 100644 --- a/spec/client/users_spec.rb +++ b/spec/client/users_spec.rb @@ -121,6 +121,16 @@ end end + describe '#reactivate_user' do + it 'returns activation token by default.' do + VCR.use_cassette('reactivate_user') do + resp, status = client.reactivate_user(USERS_USER_ID) + expect(status).to(be == 200) + expect(resp[:activationToken]).to(be == '-9OhPWRjr7_S8t2iV5_w') + end + end + end + describe '#deactivate_user' do it 'returns an empty object.' do VCR.use_cassette('deactivate_user') do @@ -130,6 +140,16 @@ end end + describe '#delete_user' do + it 'returns an empty object.' do + VCR.use_cassette('delete_user') do + resp, status = client.delete_user(USERS_USER_ID) + expect(resp).to(be_empty) + expect(status).to(be == 204) + end + end + end + describe '#suspend_user' do it 'returns an empty object.' do VCR.use_cassette('suspend_user') do