Skip to content

Commit

Permalink
Cleanup metadata tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-jackson committed Jul 23, 2024
1 parent b742091 commit 0987d57
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions tests/MetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function testMetadataFilesReturnArrays()
$spFiles = $this->getSpMetadataFiles();
foreach ($spFiles as $file) {
$returnVal = include $file;
$this->assertTrue(is_array($returnVal), 'Metadata file does not return array as expected. File: ' . $file);
$this->assertIsArray($returnVal, 'Metadata file does not return array as expected. File: ' . $file);
}

$idpFiles = $this->getIdPMetadataFiles();
foreach ($idpFiles as $file) {
$returnVal = include $file;
$this->assertTrue(is_array($returnVal), 'Metadata file does not return array as expected. File: ' . $file);
$this->assertIsArray($returnVal, 'Metadata file does not return array as expected. File: ' . $file);
}
}

Expand All @@ -74,7 +74,7 @@ public function testIDPRemoteMetadataIDPCode()
'include an ' . self::IdpCode . ' element as expected. IDP: ' . $entityId);

$nextCode = $entry[self::IdpCode];
$this->assertTrue(is_string($nextCode), 'Metadata entry has an ' .
$this->assertIsString($nextCode, 'Metadata entry has an ' .
self::IdpCode . 'element that is not a string. IDP: ' . $entityId);
$this->assertRegExp("/^[A-Za-z0-9_-]+$/", $nextCode, 'Metadata entry has an ' .
self::IdpCode . ' element that has something other than letters, ' .
Expand All @@ -101,7 +101,7 @@ public function testIDPRemoteMetadataBadSPList()
}
}

$this->assertTrue(empty($badIdps),
$this->assertEmpty($badIdps,
"At least one IdP has an " .
$spListKey . " entry that is not an array ... " . PHP_EOL .
var_export($badIdps, True));
Expand All @@ -125,7 +125,7 @@ public function testIDPRemoteMetadataMissingLogoCaption()
}
}

$this->assertTrue(empty($badIdps),
$this->assertEmpty($badIdps,
"At least one IdP is missing a " .
self::LogoCaptionKey . " entry ... " . PHP_EOL .
var_export($badIdps, True));
Expand Down Expand Up @@ -157,7 +157,7 @@ public function testIDPRemoteMetadataBadSPListEntry()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
"At least one non-existent SP is listed in an IdP's " .
$spListKey . " entry ... " . PHP_EOL .
var_export($badSps, True));
Expand All @@ -171,7 +171,7 @@ public function testIDPRemoteMetadataNoDuplicateIDPCode()

foreach ($idpEntries as $entityId => $entry) {
$nextCode = $entry[self::IdpCode];
$this->assertFalse(in_array($nextCode, $codes),
$this->assertNotContains($nextCode, $codes,
"Metadata has a duplicate " . self::IdpCode . " entry: " . $nextCode);
$codes[] = $nextCode;
}
Expand All @@ -184,8 +184,7 @@ public function testMetadataNoDuplicateEntities()
foreach ($spFiles as $file) {
$returnVal = include $file;
foreach ($returnVal as $entityId => $entity) {
$this->assertFalse(
in_array($entityId, $entities),
$this->assertNotContains($entityId, $entities,
'Duplicate entity id found in metadata file: ' . $file . '. Entity ID: ' . $entityId
);
$entities[] = $entityId;
Expand All @@ -196,8 +195,7 @@ public function testMetadataNoDuplicateEntities()
foreach ($idpFiles as $file) {
$returnVal = include $file;
foreach ($returnVal as $entityId => $entity) {
$this->assertFalse(
in_array($entityId, $entities),
$this->assertNotContains($entityId, $entities,
'Duplicate entity id found in metadata file: ' . $file . '. Entity ID: ' . $entityId
);
$entities[] = $entityId;
Expand Down Expand Up @@ -227,7 +225,7 @@ public function testMetadataNoSpsWithoutAnIdp()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
"At least one SP does not have an IdP it is allowed to use ... " .
var_export($badSps, True));
}
Expand All @@ -244,7 +242,7 @@ public function testMetadataBadIdpName()
}
}

$this->assertTrue(empty($badNames),
$this->assertEmpty($badNames,
"The following Idp's do not have a 'name' entry as an array with an 'en' entry ... " .
var_export($badNames, True));
}
Expand All @@ -261,7 +259,7 @@ public function testMetadataMissingLogoURL()
}
}

$this->assertTrue(empty($badLogos),
$this->assertEmpty($badLogos,
"The following Idp's do not have a 'logoURL' entry ... " .
var_export($badLogos, True));
}
Expand All @@ -288,7 +286,7 @@ public function testMetadataSPWithBadIDPList()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has an IDPList with a bad IDP entity id ... ' . var_export($badSps, True));

}
Expand All @@ -311,7 +309,7 @@ public function testMetadataSPWithNoIDPList()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has an empty IDPList entry (required) ... ' .
var_export($badSps, True));
}
Expand All @@ -334,7 +332,7 @@ public function testMetadataSPWithNoName()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has an empty "' . self::SPNameKey . '" entry (required) ... ' .
var_export($badSps, True));
}
Expand All @@ -356,7 +354,7 @@ public function testMetadataCerts()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has no certData entry ... ' .
var_export($badSps, True));

Expand All @@ -382,7 +380,7 @@ public function testMetadataSignResponse()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has saml20.sign.response set to false ... ' .
var_export($badSps, True));

Expand Down Expand Up @@ -412,7 +410,7 @@ public function testMetadataSignAssertion()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP has saml20.sign.assertion set to false ... ' .
var_export($badSps, True));

Expand Down Expand Up @@ -441,7 +439,7 @@ public function testMetadataEncryption()
}
}

$this->assertTrue(empty($badSps),
$this->assertEmpty($badSps,
'At least one SP does not have assertion.encryption set to True ... ' .
var_export($badSps, True));

Expand Down

0 comments on commit 0987d57

Please sign in to comment.