Code Duplication    Length = 21-22 lines in 3 locations

tests/features/bootstrap/ServiceProviderContext.php 3 locations

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