mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: update remaining tests for restored session-limit/duration bounds
PoliciesSessionLimitIntegrationTest relied on disabling the session limit (null -> unlimited), which the policy no longer supports; assert 400 instead. ProjectsConsoleClientTest set the legacy auth/duration alias to 10 seconds, below the restored 60-second floor; bump to 60 and adjust the expiry poll window accordingly.
This commit is contained in:
1 parent
5bf39b8fd2
commit
e54192c5f1
2 files changed
+13
-15
No files matched your search
@@ -73,6 +73,12 @@ final class PoliciesSessionLimitIntegrationTest extends Scope
|
||||
$this->assertSame(200, $response['headers']['status-code']);
|
||||
};
|
||||
|
||||
$trySetSessionLimit = function (?int $total) use ($serverHeaders): array {
|
||||
return $this->client->call(Client::METHOD_PATCH, '/project/policies/session-limit', $serverHeaders, [
|
||||
'total' => $total,
|
||||
]);
|
||||
};
|
||||
|
||||
// Step 1: Session limit = 1
|
||||
$setSessionLimit(1);
|
||||
|
||||
@@ -109,16 +115,8 @@ final class PoliciesSessionLimitIntegrationTest extends Scope
|
||||
$this->assertSame(200, $getAccount($session3)['headers']['status-code']);
|
||||
$this->assertSame(401, $getAccount($session2)['headers']['status-code']);
|
||||
|
||||
// Step 4: Disable session limit, create 5 new sessions, all should remain usable
|
||||
$setSessionLimit(null);
|
||||
|
||||
$newSessions = [];
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$newSessions[] = $login();
|
||||
}
|
||||
|
||||
foreach ($newSessions as $index => $sessionCookie) {
|
||||
$this->assertSame(200, $getAccount($sessionCookie)['headers']['status-code'], 'Session #' . ($index + 1) . ' should remain valid when limit is disabled');
|
||||
}
|
||||
// Step 4: Session limit does not support being disabled (unlimited sessions)
|
||||
$response = $trySetSessionLimit(null);
|
||||
$this->assertSame(400, $response['headers']['status-code']);
|
||||
}
|
||||
}
|
||||
@@ -2092,7 +2092,7 @@ final class ProjectsConsoleClientTest extends Scope
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-response-format' => '1.9.1',
|
||||
], $this->getHeaders()), [
|
||||
'duration' => 10, // Set session duration to 10 seconds
|
||||
'duration' => 60, // Set session duration to 60 seconds (the policy minimum)
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
@@ -2101,7 +2101,7 @@ final class ProjectsConsoleClientTest extends Scope
|
||||
$this->assertArrayHasKey('platforms', $response['body']);
|
||||
$this->assertArrayHasKey('webhooks', $response['body']);
|
||||
$this->assertArrayHasKey('keys', $response['body']);
|
||||
$this->assertEquals(10, $response['body']['authDuration']);
|
||||
$this->assertEquals(60, $response['body']['authDuration']);
|
||||
|
||||
$projectId = $response['body']['$id'];
|
||||
|
||||
@@ -2142,7 +2142,7 @@ final class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Eventually session expires, within 15 seconds (10+variance)
|
||||
// Eventually session expires, within 75 seconds (60+variance)
|
||||
$this->assertEventually(function () use ($projectId, $sessionCookie) {
|
||||
// Get User
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
||||
@@ -2152,7 +2152,7 @@ final class ProjectsConsoleClientTest extends Scope
|
||||
]));
|
||||
|
||||
$this->assertEquals(401, $response['headers']['status-code']);
|
||||
}, timeoutMs: 15 * 1000);
|
||||
}, timeoutMs: 75 * 1000);
|
||||
|
||||
// Set session duration to 10min
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/duration', array_merge([
|
||||
|
||||
Reference in new issue
Block a user