Skip to content

Commit

Permalink
Merge branch 'main' into add-delete_user-and-delete_user_authenticato…
Browse files Browse the repository at this point in the history
…r-method
  • Loading branch information
stevenclouston committed Oct 9, 2024
2 parents 821f424 + 3d50b4e commit bf15a21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Authsignal/Authsignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ public static function getUser(string $userId, string $redirectUrl = null)
return $response;
}

public static function updateUser(string $userId, array $data)
{
$request = new AuthsignalClient();

$userId = urlencode($userId);

$url = "/users/{$userId}";

list($response, $request) = $request->send($url, $data, 'post');

return $response;
}


/**
* Enroll Authenticators
* @param string $userId The userId of the user you are tracking the action for
Expand Down
18 changes: 18 additions & 0 deletions test/AuthsignalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,22 @@ public function testDeleteUserAuthenticator() {
$this->assertArrayHasKey("success", $response);
$this->assertEquals($response["success"], true);
}

public function testUpdateUser() {
$mockedResponse = array(
"userId" => "550e8400-e29b-41d4-a716-446655440000",
"email" => "updated_email",
);

self::$server->setResponseOfPath("/v1/users/550e8400-e29b-41d4-a716-446655440000", new Response(json_encode($mockedResponse)));

$data = array(
"email" => "updated_email",
);

$response = Authsignal::updateUser("550e8400-e29b-41d4-a716-446655440000", $data);

$this->assertEquals($response["userId"], $mockedResponse["userId"]);
$this->assertEquals($response["email"], $mockedResponse["email"]);
}
}

0 comments on commit bf15a21

Please sign in to comment.