Failed Conditions
Push — v7 ( e264c8...089db6 )
by Florent
06:30
created

KeyContext   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A iLoadAJkuKeysetFromYahoo() 0 10 2
A iLoadAJkuKeysetFromGoogle() 0 10 2
A iLoadAX5UKeysetFromAnGoogle() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Test\Context;
15
16
use Jose\Component\Core\JWKSet;
17
use Jose\Component\KeyManagement\JKUFactory;
18
use Jose\Component\KeyManagement\X5UFactory;
19
use Behat\Behat\Context\Context;
20
use Behat\Symfony2Extension\Context\KernelDictionary;
21
22
final class KeyContext implements Context
23
{
24
    use KernelDictionary;
25
    /**
26
     * @When I load a JKU keyset from Yahoo
27
     */
28
    public function iLoadAJkuKeysetFromYahoo()
29
    {
30
        /** @var JKUFactory $jkuFactory */
31
        $jkuFactory = $this->getContainer()->get(JKUFactory::class);
32
33
        $keyset = $jkuFactory->loadFromUrl('https://login.yahoo.com/openid/v1/certs');
34
        if (!$keyset instanceof JWKSet) {
35
            throw new \InvalidArgumentException('No key set received.');
36
        }
37
    }
38
39
    /**
40
     * @When I load a JKU keyset from Google
41
     */
42
    public function iLoadAJkuKeysetFromGoogle()
43
    {
44
        /** @var JKUFactory $jkuFactory */
45
        $jkuFactory = $this->getContainer()->get(JKUFactory::class);
46
47
        $keyset = $jkuFactory->loadFromUrl('https://www.googleapis.com/oauth2/v3/certs');
48
        if (!$keyset instanceof JWKSet) {
49
            throw new \InvalidArgumentException('No key set received.');
50
        }
51
    }
52
53
    /**
54
     * @When I load a X5U keyset from an Google
55
     */
56
    public function iLoadAX5UKeysetFromAnGoogle()
57
    {
58
        /** @var X5UFactory $x5uFactory */
59
        $x5uFactory = $this->getContainer()->get( X5UFactory::class);
60
61
        $keyset = $x5uFactory->loadFromUrl('https://www.googleapis.com/oauth2/v1/certs');
62
        if (!$keyset instanceof JWKSet) {
63
            throw new \InvalidArgumentException('No key set received.');
64
        }
65
    }
66
}
67