Passed
Push — master ( 6523ae...53286a )
by Stefan
07:26
created

RegProcessTest.php$0 ➔ info()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 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
     */
39
    protected function setUp(): void
40
    {
41
        parent::setUp();
42
43
        $this->config = Configuration::loadFromArray(
44
            [
45
                'module.enable' => ['webauthn' => true],
46
                'secretsalt' => 'abc123',
47
                'enable.saml20-idp' => true,
48
            ],
49
            '[ARRAY]',
50
            'simplesaml'
51
        );
52
53
        $this->session = Session::getSessionFromRequest();
54
55
        $this->logger = new class () extends Logger {
56
            public static function info($str)
57
            {
58
                // do nothing
59
            }
60
        };
61
    }
62
63
64
    /**
65
     */
66
    public function testRegProcess(): void
67
    {
68
        $this->markTestSkipped('Breaks testsuite');
69
70
        $_SERVER['REQUEST_URI'] = '/module.php/webauthn/regprocess';
71
        $request = Request::create(
72
            '/regprocess',
73
            'POST',
74
            [
75
                'StateId' => 'someStateId',
76
                'attestation_object' => 'some object',
77
                'type' => 'public-key',
78
                'response_id' => 'abc123',
79
                'attestation_client_data_json' => 'test',
80
            ]
81
        );
82
83
84
        $c = new Controller\RegProcess($this->config, $this->session);
85
        $c->setLogger($this->logger);
86
        $c->setAuthState(new class () extends State {
87
            public static function loadState($id, $stage, $allowMissing = false)
88
            {
89
                return [
90
                    'FIDO2Scope' => 'Ducktown',
91
                    'FIDO2Tokens' => [0 => 'A1B2C3', 1 => 'D4E5F6'],
92
                    'FIDO2SignupChallenge' => 'abc123',
93
                    'FIDO2AuthSuccessful' => true,
94
                    'IdPMetadata' => [
95
                        'entityid' => 'https://idp.example.com',
96
                    ],
97
                ];
98
            }
99
        });
100
101
        $response = $c->main($request);
102
103
        $this->assertTrue($response->isSuccessful());
104
    }
105
}
106