File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace UnityWebPortal \lib ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Framework \Attributes \DataProvider ;
7+
8+ class AjaxSshValidateTest extends TestCase
9+ {
10+ public static function providerTestSshValidate ()
11+ {
12+ // sanity check only, see UnitySiteTest for more comprehensive test cases
13+ return [
14+ [false , "foobar " ],
15+ // phpcs:disable
16+ [true , "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+XqO25MUB9x/pS04I3JQ7rMGboWyGXh0GUzkOrTi7a " ],
17+ // phpcs:enable
18+ ];
19+ }
20+
21+ #[DataProvider("providerTestSshValidate " )]
22+ public function testSshValidate (bool $ is_valid , string $ pubkey )
23+ {
24+ $ _SERVER ["REQUEST_METHOD " ] = "POST " ;
25+ $ _POST ["key " ] = $ pubkey ;
26+ ob_start ();
27+ include "../../webroot/js/ajax/ssh_validate.php " ;
28+ $ output = ob_get_clean ();
29+ if ($ is_valid ) {
30+ $ this ->assertEquals ("true " , $ output );
31+ } else {
32+ $ this ->assertEquals ("false " , $ output );
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments