Passed
Pull Request — master (#31)
by Tim
02:17
created

RegProcessTest.php$0 ➔ setUp()   A

Complexity

Conditions 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
rs 9.6333
cc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A RegProcessTest.php$0 ➔ info() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\Module\webauthn\Controller;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\Auth\State;
9
use SimpleSAML\Configuration;
10
use SimpleSAML\Error;
11
use SimpleSAML\HTTP\RunnableResponse;
12
use SimpleSAML\Logger;
13
use SimpleSAML\Module\webauthn\Controller;
14
use SimpleSAML\Session;
15
use SimpleSAML\Utils;
16
use SimpleSAML\XHTML\Template;
17
use Symfony\Component\HttpFoundation\Request;
18
19
/**
20
 * Set of tests for the controllers in the "webauthn" module.
21
 *
22
 * @package SimpleSAML\Test
23
 */
24
class RegProcessTest extends TestCase
25
{
26
    /** @var \SimpleSAML\Configuration */
27
    protected $config;
28
29
    /** @var \SimpleSAML\Logger */
30
    protected $logger;
31
32
    /** @var \SimpleSAML\Session */
33
    protected $session;
34
35
36
    /**
37
     * Set up for each test.
38
     * @return void
39
     */
40
    protected function setUp(): void
41
    {
42
        parent::setUp();
43
44
        $this->config = Configuration::loadFromArray(
45
            [
46
                'module.enable' => ['webauthn' => true],
47
                'secretsalt' => 'abc123',
48
                'enable.saml20-idp' => true,
49
            ],
50
            '[ARRAY]',
51
            'simplesaml'
52
        );
53
54
        $this->session = Session::getSessionFromRequest();
55
56
        $this->logger = new class () extends Logger {
57
            public static function info(string $str): void
58
            {
59
                // do nothing
60
            }
61
        };
62
    }
63
64
65
    /**
66
     * @return void
67
     */
68
    public function testRegProcess(): void
69
    {
70
        $this->markTestSkipped('Breaks testsuite');
71
72
        $_SERVER['REQUEST_URI'] = '/module.php/webauthn/regprocess';
73
        $request = Request::create(
74
            '/regprocess',
75
            'GET',
76
            ['StateId' => 'someStateId']
77
        );
78
79
80
        $c = new Controller\RegProcess($this->config, $this->session);
81
        $c->setLogger($this->logger);
82
        $c->setAuthState(new class () extends State {
83
            public static function loadState(string $id, string $stage, bool $allowMissing = false): ?array
84
            {
85
                return [
86
//                    'FIDO2Displayname' => 'Donald Duck',
87
//                    'FIDO2Username' => 'dduck',
88
//                    'FIDO2Scope' => 'Ducktown',
89
//                    'FIDO2Tokens' => [],
90
//                    'FIDO2SignupChallenge' => 'abc123',
91
//                    'FIDO2AuthSuccessful' => true,
92
//                    'requestTokenModel' => 'something',
93
//                    'Source' => [
94
//                        'entityid' => 'https://idp.example.com',
95
//                    ],
96
                ];
97
            }
98
        });
99
100
        $response = $c->main($request);
101
102
        $this->assertTrue($response->isSuccessful());
103
    }
104
}
105