From 0c2badc113707c2afd39c6f102a9be1a52e919c7 Mon Sep 17 00:00:00 2001 From: Luca Cracco Date: Tue, 5 Mar 2024 18:20:38 +0100 Subject: [PATCH] Fix PHPUnit test: 'Can load all idp metadata' --- tests/SpTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/SpTest.php b/tests/SpTest.php index 1ba7376..66d8ce9 100644 --- a/tests/SpTest.php +++ b/tests/SpTest.php @@ -296,14 +296,16 @@ public function testCanLoadAllIdpMetadata() $retrievedIdp = $sp->loadIdpFromFile($idp); $this->assertEquals($retrievedIdp->idpFileName, $idp); $idpEntityId = $retrievedIdp->metadata['idpEntityId']; - $host = parse_url($idpEntityId, PHP_URL_HOST); + preg_match("/[a-z0-9\-]{1,63}\.[a-z\.]{2,6}$/", parse_url($idpEntityId, PHP_URL_HOST), $base_domain_tld); $idpSSOArray = $retrievedIdp->metadata['idpSSO']; foreach ($idpSSOArray as $key => $idpSSO) { - $this->assertStringContainsString($host, $idpSSO['location']); + preg_match("/[a-z0-9\-]{1,63}\.[a-z\.]{2,6}$/", parse_url($idpSSO['location'], PHP_URL_HOST), $domain_tld); + $this->assertStringContainsString($base_domain_tld[0], $domain_tld[0]); } $idpSLOArray = $retrievedIdp->metadata['idpSLO']; foreach ($idpSLOArray as $key => $idpSLO) { - $this->assertStringContainsString($host, $idpSLO['location']); + preg_match("/[a-z0-9\-]{1,63}\.[a-z\.]{2,6}$/", parse_url($idpSLO['location'], PHP_URL_HOST), $domain_tld); + $this->assertStringContainsString($base_domain_tld[0], $domain_tld[0]); } } // If IDPs were downloaded for testing purposes, then delete them