Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/NGINXTest.php
Show All 12 Lines | class NGINXTest extends TestCase | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
\App\CompanionApp::where('user_id', $john->id)->delete(); | \App\CompanionApp::where('user_id', $john->id)->delete(); | ||||
\App\AuthAttempt::where('user_id', $john->id)->delete(); | \App\AuthAttempt::where('user_id', $john->id)->delete(); | ||||
$john->setSettings([ | $john->setSettings([ | ||||
'limit_geo' => null, | 'limit_geo' => null, | ||||
'guam_enabled' => false, | 'guam_enabled' => null, | ||||
]); | ]); | ||||
\App\IP4Net::where('net_number', '127.0.0.0')->delete(); | \App\IP4Net::where('net_number', '127.0.0.0')->delete(); | ||||
$this->useServicesUrl(); | $this->useServicesUrl(); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
\App\CompanionApp::where('user_id', $john->id)->delete(); | \App\CompanionApp::where('user_id', $john->id)->delete(); | ||||
\App\AuthAttempt::where('user_id', $john->id)->delete(); | \App\AuthAttempt::where('user_id', $john->id)->delete(); | ||||
$john->setSettings([ | $john->setSettings([ | ||||
'limit_geo' => null, | 'limit_geo' => null, | ||||
'guam_enabled' => false, | 'guam_enabled' => null, | ||||
]); | ]); | ||||
\App\IP4Net::where('net_number', '127.0.0.0')->delete(); | \App\IP4Net::where('net_number', '127.0.0.0')->delete(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test the webhook | * Test the webhook | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | public function testNGINXWebhook(): void | ||||
$modifiedHeaders = $headers; | $modifiedHeaders = $headers; | ||||
$modifiedHeaders['Auth-Protocol'] = ""; | $modifiedHeaders['Auth-Protocol'] = ""; | ||||
$response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx"); | $response = $this->withHeaders($modifiedHeaders)->get("api/webhooks/nginx"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$response->assertHeader('auth-status', 'authentication failure'); | $response->assertHeader('auth-status', 'authentication failure'); | ||||
// Guam | // Guam | ||||
$john->setSettings(['guam_enabled' => true]); | $john->setSettings(['guam_enabled' => 'true']); | ||||
$response = $this->withHeaders($headers)->get("api/webhooks/nginx"); | $response = $this->withHeaders($headers)->get("api/webhooks/nginx"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$response->assertHeader('auth-status', 'OK'); | $response->assertHeader('auth-status', 'OK'); | ||||
$response->assertHeader('auth-server', '127.0.0.1'); | $response->assertHeader('auth-server', '127.0.0.1'); | ||||
$response->assertHeader('auth-port', '9143'); | $response->assertHeader('auth-port', '9143'); | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |