1
0
Fork 0
mirror of synced 2024-09-28 23:41:23 +12:00

test: fix magic url assertions

This commit is contained in:
loks0n 2023-10-10 14:36:53 +01:00
parent a88175fc46
commit c30c024805
3 changed files with 7 additions and 7 deletions

View file

@ -1012,7 +1012,7 @@ App::post('/v1/account/sessions/magic-url')
} }
$url = Template::parseURL($url); $url = Template::parseURL($url);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $loginSecret, 'expire' => $expire, 'project' => $project->getId()]); $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $tokenSecret, 'expire' => $expire, 'project' => $project->getId()]);
$url = Template::unParseURL($url); $url = Template::unParseURL($url);
$body = $locale->getText("emails.magicSession.body"); $body = $locale->getText("emails.magicSession.body");
@ -1102,7 +1102,7 @@ App::post('/v1/account/sessions/magic-url')
); );
// Hide secret for clients // Hide secret for clients
$token->setAttribute('secret', $tokenSecret); $token->setAttribute('secret', ($isPrivilegedUser || $isAppUser) ? $tokenSecret : '');
$response $response
->setStatusCode(Response::STATUS_CODE_CREATED) ->setStatusCode(Response::STATUS_CODE_CREATED)

View file

@ -1300,7 +1300,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']); $this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['secret']); $this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire'])); $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire']));
$userId = $response['body']['userId']; $userId = $response['body']['userId'];
@ -1393,6 +1393,7 @@ trait AccountBase
$this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['userId']); $this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['secret']);
$sessionId = $response['body']['$id']; $sessionId = $response['body']['$id'];
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']]; $session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
@ -1407,7 +1408,6 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['registration'])); $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email); $this->assertEquals($response['body']['email'], $email);
$this->assertTrue($response['body']['emailVerification']); $this->assertTrue($response['body']['emailVerification']);
@ -1468,7 +1468,6 @@ trait AccountBase
$this->assertIsArray($response['body']); $this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['registration'])); $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email); $this->assertEquals($response['body']['email'], $email);
@ -1482,6 +1481,7 @@ trait AccountBase
]); ]);
$this->assertEquals($response['headers']['status-code'], 201); $this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']['secret']);
/** /**
* Test for FAILURE * Test for FAILURE

View file

@ -760,7 +760,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']); $this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['secret']); $this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire'])); $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire']));
$userId = $response['body']['userId']; $userId = $response['body']['userId'];
@ -1003,7 +1003,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']); $this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']); $this->assertNotEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire'])); $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire']));
\sleep(2); \sleep(2);