Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add method deleteAllAuthenticators to the users management api #702

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/API/Management/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,21 @@ public function deleteMultifactorProvider(
withOptions($options)->
call();
}

public function deleteAllAuthenticators(
string $id,
?RequestOptions $options = null,
): ResponseInterface {
[$id] = Toolkit::filter([$id])->string()->trim();

Toolkit::assert([
[$id, \Auth0\SDK\Exception\ArgumentException::missing('id')],
])->isString();

return $this->getHttpClient()->
method('delete')->
addPath('users', $id, 'authenticators')->
withOptions($options)->
call();
}
}
18 changes: 18 additions & 0 deletions src/Contract/API/Management/UsersInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,22 @@ public function deleteMultifactorProvider(
string $provider,
?RequestOptions $options = null,
): ResponseInterface;

/**
* Deletes all authenticators that are associated to the provided user.
*
* Required scope: `delete:guardian_enrollments`.
*
* @param string $id user ID with the authenticators to delete
* @param RequestOptions|null $options Optional. Additional request options to use, such as a field filtering or pagination. (Not all endpoints support these. See @see for supported options.)
*
* @throws \Auth0\SDK\Exception\ArgumentException when an invalid `id` is provided
* @throws \Auth0\SDK\Exception\NetworkException when the API request fails due to a network error
*
* @see https://auth0.com/docs/api/management/v2#!/Users/delete_authenticators
*/
public function deleteAllAuthenticators(
string $id,
?RequestOptions $options = null,
): ResponseInterface;
}
13 changes: 13 additions & 0 deletions tests/Unit/API/Management/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@
expect($headers['Content-Type'][0])->toEqual('application/json');
});

test('deleteAllAuthenticators() issues an appropriate request', function(): void {
$id = uniqid();

$this->endpoint->deleteAllAuthenticators($id);

expect($this->api->getRequestMethod())->toEqual('DELETE');
expect($this->api->getRequestUrl())->toEndWith('/api/v2/users/' . $id . '/authenticators');

$headers = $this->api->getRequestHeaders();
expect($headers['Content-Type'][0])->toEqual('application/json');
});


test('getRoles() issues an appropriate request', function(): void {
$mockupId = uniqid();

Expand Down