Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/NGINXTest.php
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | class NGINXTest extends TestCase | ||||
/** | /** | ||||
* Test the httpauth webhook | * Test the httpauth webhook | ||||
*/ | */ | ||||
public function testNGINXHttpAuthHook(): void | public function testNGINXHttpAuthHook(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$response = $this->get("api/webhooks/nginx-httpauth"); | $response = $this->get("api/webhooks/nginx-httpauth"); | ||||
$response->assertStatus(401); | $response->assertStatus(200); | ||||
$pass = \App\Utils::generatePassphrase(); | $pass = \App\Utils::generatePassphrase(); | ||||
$headers = [ | $headers = [ | ||||
'Php-Auth-Pw' => $pass, | 'Php-Auth-Pw' => $pass, | ||||
'Php-Auth-User' => 'john@kolab.org', | 'Php-Auth-User' => 'john@kolab.org', | ||||
'X-Forwarded-For' => '127.0.0.1', | 'X-Forwarded-For' => '127.0.0.1', | ||||
'X-Forwarded-Proto' => 'https', | 'X-Forwarded-Proto' => 'https', | ||||
'X-Original-Uri' => '/iRony/', | 'X-Original-Uri' => '/iRony/', | ||||
Show All 21 Lines | public function testNGINXHttpAuthHook(): void | ||||
$modifiedHeaders['Php-Auth-Pw'] = ""; | $modifiedHeaders['Php-Auth-Pw'] = ""; | ||||
$response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | $response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | ||||
$response->assertStatus(401); | $response->assertStatus(401); | ||||
// Empty User | // Empty User | ||||
$modifiedHeaders = $headers; | $modifiedHeaders = $headers; | ||||
$modifiedHeaders['Php-Auth-User'] = ""; | $modifiedHeaders['Php-Auth-User'] = ""; | ||||
$response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | $response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | ||||
$response->assertStatus(403); | $response->assertStatus(200); | ||||
// Invalid User | // Invalid User | ||||
$modifiedHeaders = $headers; | $modifiedHeaders = $headers; | ||||
$modifiedHeaders['Php-Auth-User'] = "foo@kolab.org"; | $modifiedHeaders['Php-Auth-User'] = "foo@kolab.org"; | ||||
$response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | $response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx-httpauth"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Empty Ip | // Empty Ip | ||||
Show All 33 Lines |