Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117762357
D5052.1775216398.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D5052.1775216398.diff
View Options
diff --git a/src/tests/Feature/Controller/NGINXTest.php b/src/tests/Feature/Controller/NGINXTest.php
--- a/src/tests/Feature/Controller/NGINXTest.php
+++ b/src/tests/Feature/Controller/NGINXTest.php
@@ -314,6 +314,32 @@
*/
public function testCyrusSaslHook(): void
{
- $this->markTestIncomplete();
+ $pass = \App\Utils::generatePassphrase();
+
+ // Pass
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john kolab.org $pass");
+ $response->assertStatus(200);
+
+ // Pass without realm
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john@kolab.org $pass");
+ $response->assertStatus(200);
+
+ // Invalid password
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john kolab.org fail");
+ $response->assertStatus(403);
+
+ $this->getTestUser('cyrus-admin');
+
+ // service-account Pass
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "cyrus-admin $pass");
+ $response->assertStatus(200);
+
+ // service-account fail
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "cyrus-admin fail");
+ $response->assertStatus(403);
+
+ // unknown user fail
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "missing@kolab.org $pass");
+ $response->assertStatus(403);
}
}
diff --git a/src/tests/TestCase.php b/src/tests/TestCase.php
--- a/src/tests/TestCase.php
+++ b/src/tests/TestCase.php
@@ -105,4 +105,15 @@
\config(['app.url' => str_replace('//', '//services.', \config('app.url'))]);
url()->forceRootUrl(config('app.url'));
}
+
+
+ /**
+ * The test equivalent of Http::withBody, which is not available for tests.
+ *
+ * Required to test request handlers that use Request::getContent
+ */
+ protected function postWithBody($url, $content)
+ {
+ return $this->call('POST', $url, [], [], [], [], $content);
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 11:39 AM (8 h, 58 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823862
Default Alt Text
D5052.1775216398.diff (1 KB)
Attached To
Mode
D5052: Test the sasl auth hook
Attached
Detach File
Event Timeline