Code Duplication    Length = 22-22 lines in 2 locations

tests/features/bootstrap/ServiceProviderContext.php 2 locations

@@ 154-175 (lines=22) @@
151
    /**
152
     * @When /^([^\']*) starts an SFO authentication$/
153
     */
154
    public function iStartAnSFOAuthentication($nameId)
155
    {
156
        $authnRequest = new AuthnRequest();
157
        // In order to later assert if the response succeeded or failed, set our own dummy ACS location
158
        $authnRequest->setAssertionConsumerServiceURL(SamlEntityRepository::SP_ACS_LOCATION);
159
        $authnRequest->setIssuer($this->currentSfoSp['entityId']);
160
        $authnRequest->setDestination(self::SFO_ENDPOINT_URL);
161
        $authnRequest->setProtocolBinding(Constants::BINDING_HTTP_REDIRECT);
162
        $authnRequest->setNameId($this->buildNameId($nameId));
163
        // Sign with random key, does not mather for now.
164
        // todo: use from services_test.yml
165
        $authnRequest->setSignatureKey(
166
            $this->loadPrivateKey(new PrivateKey('/var/www/ci/certificates/sp.pem', 'default'))
167
        );
168
        $authnRequest->setRequestedAuthnContext(
169
            ['AuthnContextClassRef' => ['http://stepup.example.com/assurance/sfo-level2']]
170
        );
171
        $request = Saml2AuthnRequest::createNew($authnRequest);
172
        $query = $request->buildRequestQuery();
173
174
        $this->getSession()->visit($request->getDestination().'?'.$query);
175
    }
176
177
    /**
178
     * @When /^([^\']*) starts an SFO authentication requiring ([^\']*)$/
@@ 180-201 (lines=22) @@
177
    /**
178
     * @When /^([^\']*) starts an SFO authentication requiring ([^\']*)$/
179
     */
180
    public function iStartAnSFOAuthenticationWithLoaRequirement($nameId, $loa)
181
    {
182
        $authnRequest = new AuthnRequest();
183
        // In order to later assert if the response succeeded or failed, set our own dummy ACS location
184
        $authnRequest->setAssertionConsumerServiceURL(SamlEntityRepository::SP_ACS_LOCATION);
185
        $authnRequest->setIssuer($this->currentSfoSp['entityId']);
186
        $authnRequest->setDestination(self::SFO_ENDPOINT_URL);
187
        $authnRequest->setProtocolBinding(Constants::BINDING_HTTP_REDIRECT);
188
        $authnRequest->setNameId($this->buildNameId($nameId));
189
        // Sign with random key, does not mather for now.
190
        // todo: use from services_test.yml
191
        $authnRequest->setSignatureKey(
192
            $this->loadPrivateKey(new PrivateKey('/var/www/ci/certificates/sp.pem', 'default'))
193
        );
194
        $authnRequest->setRequestedAuthnContext(
195
            ['AuthnContextClassRef' => [$loa]]
196
        );
197
        $request = Saml2AuthnRequest::createNew($authnRequest);
198
        $query = $request->buildRequestQuery();
199
200
        $this->getSession()->visit($request->getDestination().'?'.$query);
201
    }
202
203
    /**
204
     * @When /^([^\']*) starts an authentication$/