Skip to content

Commit 708060c

Browse files
committed
Remove legacy code
1 parent 77084b8 commit 708060c

2 files changed

Lines changed: 17 additions & 35 deletions

File tree

tests/Alg/HMACSignatureTest.php

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use SimpleSAML\XMLSecurity\Key\PublicKey;
1313
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
1414
use SimpleSAML\XMLSecurity\Key\X509Certificate;
15+
use TypeError;
1516

1617
/**
1718
* Tests for SimpleSAML\XMLSecurity\Alg\Signature\HMAC.
@@ -158,15 +159,10 @@ public function testVerificationFailure()
158159
public function testVerifyWithCertificate()
159160
{
160161
$cert = X509Certificate::fromFile('tests/mycert.pem');
161-
if (version_compare(phpversion(), '7.0', '>=')) {
162-
// test type errors when possible
163-
$this->expectException(\TypeError::class);
164-
new HMAC($cert);
165-
} else {
166-
// test via factory
167-
$this->expectException(\RuntimeException::class);
168-
$this->factory->getAlgorithm(Constants::SIG_HMAC_SHA1, $cert);
169-
}
162+
163+
// test type errors when possible
164+
$this->expectException(TypeError::class);
165+
new HMAC($cert);
170166
}
171167

172168

@@ -176,15 +172,10 @@ public function testVerifyWithCertificate()
176172
public function testVerifyWithPublicKey()
177173
{
178174
$key = PublicKey::fromFile('tests/pubkey.pem');
179-
if (version_compare(phpversion(), '7.0', '>=')) {
180-
// test type errors when possible
181-
$this->expectException(\TypeError::class);
182-
new HMAC($key);
183-
} else {
184-
// test via factory
185-
$this->expectException(RuntimeException::class);
186-
$this->factory->getAlgorithm(Constants::SIG_HMAC_SHA1, $key);
187-
}
175+
176+
// test type errors when possible
177+
$this->expectException(TypeError::class);
178+
new HMAC($key);
188179
}
189180

190181

@@ -194,14 +185,9 @@ public function testVerifyWithPublicKey()
194185
public function testVerifyWithPrivateKey()
195186
{
196187
$key = PrivateKey::fromFile('tests/privkey.pem');
197-
if (version_compare(phpversion(), '7.0', '>=')) {
198-
// test type errors when possible
199-
$this->expectException(\TypeError::class);
200-
new HMAC($key);
201-
} else {
202-
// test via factory
203-
$this->expectException(RuntimeException::class);
204-
$this->factory->getAlgorithm(Constants::SIG_HMAC_SHA1, $key);
205-
}
188+
189+
// test type errors when possible
190+
$this->expectException(TypeError::class);
191+
new HMAC($key);
206192
}
207193
}

tests/Alg/RSASignatureTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use SimpleSAML\XMLSecurity\Key\PublicKey;
1313
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
1414
use SimpleSAML\XMLSecurity\Key\X509Certificate;
15+
use TypeError;
1516

1617
/**
1718
* Tests for SimpleSAML\XMLSecurity\Alg\Signature\RSA.
@@ -268,13 +269,8 @@ public function testVerificationFailure()
268269
public function testVerifyWithSymmetricKey()
269270
{
270271
$key = SymmetricKey::generate(16);
271-
if (version_compare(phpversion(), '7.0', '>=')) {
272-
$this->expectException(\TypeError::class);
273-
new RSA($key);
274-
} else {
275-
// test via factory
276-
$this->expectException(RuntimeException::class);
277-
$this->factory->getAlgorithm(Constants::SIG_RSA_SHA1, $key);
278-
}
272+
273+
$this->expectException(TypeError::class);
274+
new RSA($key);
279275
}
280276
}

0 commit comments

Comments
 (0)