1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

Change factors code and update Response model tests

This commit is contained in:
Bradley Schofield 2024-02-26 11:50:25 +00:00
parent 7ad4af8d91
commit f4b8ae8b88
2 changed files with 71 additions and 3 deletions

View file

@ -551,12 +551,11 @@ class V20 extends Migration
$document->setAttribute('expire', $expire);
$factors = match ($document->getAttribute('provider')) {
Auth::SESSION_PROVIDER_MAGIC_URL,
Auth::SESSION_PROVIDER_OAUTH2 => ['email'],
Auth::SESSION_PROVIDER_EMAIL => ['password'],
Auth::SESSION_PROVIDER_PHONE => ['phone'],
Auth::SESSION_PROVIDER_ANONYMOUS => ['anonymous'],
Auth::SESSION_PROVIDER_TOKEN => ['token'],
default => ['password'],
default => ['email'],
};
$document->setAttribute('factors', $factors);

View file

@ -73,6 +73,8 @@ class V17Test extends TestCase
'remove targets' => [
[
'targets' => 'test',
'mfa' => 'test',
'totp' => 'test',
],
[
],
@ -116,4 +118,71 @@ class V17Test extends TestCase
$this->assertEquals($expected, $result);
}
public function membershipProvider(): array
{
return [
'remove mfa' => [
[
'mfa' => 'test',
],
[
],
],
];
}
/**
* @dataProvider membershipProvider
*/
public function testMembership(array $content, array $expected): void
{
$model = Response::MODEL_MEMBERSHIP;
$result = $this->filter->parse($content, $model);
$this->assertEquals($expected, $result);
}
public function sessionProvider(): array
{
return [
'remove factors and secrets' => [
[
'factors' => 'test',
'secret' => 'test',
],
[
],
]
];
}
/**
* @dataProvider sessionProvider
*/
public function testSession(array $content, array $expected): void
{
$model = Response::MODEL_SESSION;
$result = $this->filter->parse($content, $model);
$this->assertEquals($expected, $result);
}
public function webhookProvider(): array
{
return [
'remove webhook additions' => [
[
'enabled' => true,
'logs' => ['test', 'test'],
'attempts' => 1
],
[
],
],
];
}
}