mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
improve devkey test for oauth
This commit is contained in:
@@ -738,6 +738,7 @@ services:
|
||||
depends_on:
|
||||
- redis
|
||||
- maildev
|
||||
- ${_APP_DB_HOST:-mariadb}
|
||||
# - smtp
|
||||
environment:
|
||||
- _APP_ENV
|
||||
|
||||
@@ -5376,7 +5376,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||
]);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
/** Test oauth2 with devKey and now get oauth2 is disabled */
|
||||
/** Test oauth2 with devKey and now flow works with untrusted URL too */
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
@@ -5385,7 +5385,36 @@ class ProjectsConsoleClientTest extends Scope
|
||||
'success' => 'https://example.com',
|
||||
'failure' => 'https://example.com'
|
||||
], followRedirects: false);
|
||||
|
||||
$this->assertEquals(301, $response['headers']['status-code']);
|
||||
$this->assertArrayHasKey('location', $response['headers']);
|
||||
|
||||
$location = $response['headers']['location'];
|
||||
|
||||
|
||||
$locationClient = new Client();
|
||||
$locationClient->setEndpoint('');
|
||||
$locationClient->addHeader('x-appwrite-dev-key', $devKey['secret']);
|
||||
|
||||
$response = $locationClient->call(Client::METHOD_GET, $location, followRedirects: false);
|
||||
|
||||
$this->assertEquals(301, $response['headers']['status-code']);
|
||||
$this->assertArrayHasKey('location', $response['headers']);
|
||||
|
||||
$location = $response['headers']['location'];
|
||||
$this->assertStringStartsWith('http://appwrite:/v1/account/sessions/oauth2/callback/mock/', $response['headers']['location']);
|
||||
|
||||
$response = $locationClient->call(Client::METHOD_GET, $location, followRedirects: false);
|
||||
$this->assertEquals(301, $response['headers']['status-code']);
|
||||
$this->assertArrayHasKey('location', $response['headers']);
|
||||
|
||||
$location = $response['headers']['location'];
|
||||
$this->assertStringStartsWith('http://appwrite:/v1/account/sessions/oauth2/mock/redirect', $response['headers']['location']);
|
||||
|
||||
$response = $locationClient->call(Client::METHOD_GET, $location, followRedirects: false);
|
||||
|
||||
$this->assertEquals(301, $response['headers']['status-code']);
|
||||
$this->assertSame('https://example.com/#', $response['headers']['location']);
|
||||
|
||||
/** Ensure any hostname is allowed */
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [
|
||||
|
||||
Reference in New Issue
Block a user