diff --git a/tests/integration/lib/REST/EfficiencyControllerProviderTest.php b/tests/integration/lib/REST/EfficiencyControllerProviderTest.php index 5ad68e53..f391f74f 100644 --- a/tests/integration/lib/REST/EfficiencyControllerProviderTest.php +++ b/tests/integration/lib/REST/EfficiencyControllerProviderTest.php @@ -5,7 +5,7 @@ use IntegrationTests\BaseTest; use IntegrationTests\TestHarness\XdmodTestHelper; -class EfficiencyTest extends BaseTest +class EfficiencyControllerProviderTest extends BaseTest { const ENDPOINT = 'rest/v1/efficiency/'; diff --git a/tests/integration/lib/REST/Warehouse/JobViewerTest.php b/tests/integration/lib/REST/Warehouse/JobViewerTest.php index 969ae284..e03d4d90 100644 --- a/tests/integration/lib/REST/Warehouse/JobViewerTest.php +++ b/tests/integration/lib/REST/Warehouse/JobViewerTest.php @@ -408,13 +408,12 @@ public function jobTimeseriesProvider() $ret[] = array($xdmodhelper, $searchparams, 'application/pdf', 'application/pdf; charset=binary'); $searchparams['format'] = 'csv'; - $ret[] = array($xdmodhelper, $searchparams, 'text/csv;charset=UTF-8', 'application/csv; charset=us-ascii'); - + $ret[] = array($xdmodhelper, $searchparams, 'text/csv;charset=UTF-8', 'text/plain; charset=us-ascii'); $searchparams['format'] = 'png'; $ret[] = array($xdmodhelper, $searchparams, 'image/png', 'image/png; charset=binary'); $searchparams['format'] = 'svg'; - $ret[] = array($xdmodhelper, $searchparams, 'image/svg+xml', 'image/svg+xml; charset=us-ascii'); + $ret[] = array($xdmodhelper, $searchparams, 'image/svg+xml', 'image/svg; charset=us-ascii'); return $ret; diff --git a/tests/integration/lib/REST/internal_dashboard/DashboardSupremmTest.php b/tests/integration/lib/REST/internal_dashboard/DashboardSupremmTest.php index c4318949..90580be2 100644 --- a/tests/integration/lib/REST/internal_dashboard/DashboardSupremmTest.php +++ b/tests/integration/lib/REST/internal_dashboard/DashboardSupremmTest.php @@ -7,23 +7,25 @@ class DashboardSupremmTest extends TestCase { - public function __construct($name, $data, $dataName) + const ENDPOINT = 'rest/v0.1/supremm_dataflow/'; + + protected static $xdmodhelper; + protected static $validateAsUser; + + public static function setUpBeforeClass(): void { $xdmodConfig = array( "decodetextasjson" => true ); - $this->xdmodhelper = new XdmodTestHelper($xdmodConfig); - - $this->endpoint = 'rest/v0.1/supremm_dataflow/'; + self::$xdmodhelper = new XdmodTestHelper($xdmodConfig); // validate as manager, for dashboard access - $this->validateAsUser = 'mgr'; - parent::__construct($name, $data, $dataName); + self::$validateAsUser = 'mgr'; } private function invalidSupremmResourceEntries($params) { // without performing validation: expect to receive a 401; // if wrong user authenticated: expect to receive a 403 - $result = $this->xdmodhelper->get($this->endpoint . 'resources', $params); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'resources', $params); // expect success to be false $this->assertArrayHasKey('success', $result[0]); @@ -38,9 +40,9 @@ private function invalidSupremmResourceEntries($params) private function validateSupremmResourceEntries() { - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); - $result = $this->xdmodhelper->get($this->endpoint . 'resources', null); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'resources', null); $this->assertEquals(200, $result[1]['http_code']); $this->assertArrayHasKey('success', $result[0]); @@ -70,13 +72,15 @@ private function fetchResourceId() private function invalidSupremmDbstatsEntries($db) { // without performing validation : expect to receive a 401 + // ensure user is logged out + self::$xdmodhelper->logoutDashboard(); // hardcode the params for resource id $params = array( 'resource_id' => 2791, 'db_id' => $db ); - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', $params); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', $params); $this->assertArrayHasKey('success', $result[0]); $this->assertFalse($result[0]['success']); @@ -88,10 +92,10 @@ private function invalidSupremmDbstatsEntries($db) private function invalidParamsSupremmDbstatsEntries() { // validate properly - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); // send null params, expect 400 - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', null); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', null); $this->assertEquals(400, $result[1]['http_code']); $this->assertArrayHasKey('success', $result[0]); @@ -101,17 +105,17 @@ private function invalidParamsSupremmDbstatsEntries() private function invalidResParamsNotFoundSupremmDbstatsEntries() { // validate properly - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); // hardcode and send bogus resource_id param $params = array( 'resource_id' => 99999, 'db_id' => 'summarydb' ); - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', $params); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', $params); // Message will contain "no result found" - $this->assertContains("no result found for the given database", $result[0]['message']); + $this->assertStringContainsString("no result found for the given database", $result[0]['message']); // result has success='false' $this->assertArrayHasKey('success', $result[0]); @@ -124,17 +128,17 @@ private function invalidResParamsNotFoundSupremmDbstatsEntries() private function invalidParamsNotFoundSupremmDbstatsEntries() { // validate properly - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); // hardcode and send bogus db_id param $params = array( 'resource_id' => $this->fetchResourceId(), 'db_id' => 'db_does_not_exist' ); - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', $params); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', $params); // Message will contain "no result found" - $this->assertContains("no result found for the given database", $result[0]['message']); + $this->assertStringContainsString("no result found for the given database", $result[0]['message']); // result has success='false' $this->assertArrayHasKey('success', $result[0]); @@ -156,8 +160,8 @@ private function invalidSupremmUserDbstatsEntries($db, $userRole) ); // reauthenticate as some (invalid) user role, not a 'mgr' role - $this->xdmodhelper->authenticate($userRole); - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', $params); + self::$xdmodhelper->authenticate($userRole); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', $params); // result has success='false' $this->assertArrayHasKey('success', $result[0]); @@ -169,13 +173,13 @@ private function invalidSupremmUserDbstatsEntries($db, $userRole) private function validateSupremmDbstatsEntries($db) { - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); $params = array( 'resource_id' => $this->fetchResourceId(), 'db_id' => $db ); - $result = $this->xdmodhelper->get($this->endpoint . 'dbstats', $params); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'dbstats', $params); $this->assertEquals(200, $result[1]['http_code']); // result has success='true' @@ -193,7 +197,7 @@ public function testInvalidUserCDSupremmResourceEntries() { // with wrong user authenticated: expect to receive a 403 $user = 'cd'; - $this->xdmodhelper->authenticate($user); + self::$xdmodhelper->authenticate($user); $result = $this->invalidSupremmResourceEntries(null); $this->assertEquals(403, $result[1]['http_code']); @@ -201,6 +205,7 @@ public function testInvalidUserCDSupremmResourceEntries() public function testInvalidUserSupremmResourceEntries() { + self::$xdmodhelper->logoutDashboard(); // with no user authenticated: expect to receive a 401 $result = $this->invalidSupremmResourceEntries(null); $this->assertEquals(401, $result[1]['http_code']); @@ -258,7 +263,7 @@ public function testFetchDbstatsSummary($db = 'summarydb') { // fetch accountdb stats public function testFetchDbstatsAccount($db = 'accountdb') { - $this->markTestIncomplete('This enpoint only works on the XSEDE version of XDMoD.'); + $this->markTestIncomplete('This endpoint only works on the XSEDE version of XDMoD.'); $item = $this->validateSupremmDbstatsEntries($db); @@ -293,19 +298,19 @@ public function testFetchDbstatsAggregates($db = 'aggregates') { public function testResourceEnableDisable() { - $this->xdmodhelper->authenticate($this->validateAsUser); + self::$xdmodhelper->authenticate(self::$validateAsUser); - $result = $this->xdmodhelper->get($this->endpoint . 'resources', null); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'resources', null); $this->assertEquals(5, sizeof($result[0]['data'])); shell_exec('mv /etc/xdmod/supremm_resources.json /etc/xdmod/supremm_resources.json.bak && jq \'.resources |= map(if .resource == "frearson" then .enabled |= false else . end)\' /etc/xdmod/supremm_resources.json.bak > /etc/xdmod/supremm_resources.json'); - $result = $this->xdmodhelper->get($this->endpoint . 'resources', null); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'resources', null); $this->assertEquals(4, sizeof($result[0]['data'])); shell_exec('mv /etc/xdmod/supremm_resources.json.bak /etc/xdmod/supremm_resources.json'); - $result = $this->xdmodhelper->get($this->endpoint . 'resources', null); + $result = self::$xdmodhelper->get(self::ENDPOINT . 'resources', null); $this->assertEquals(5, sizeof($result[0]['data'])); } }