Skip to content

Commit

Permalink
Add a few more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwhite4 authored and ryanrath committed Jul 12, 2017
1 parent a081bd9 commit 8fa9633
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions tests/integration_tests/lib/REST/Warehouse/JobViewerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,71 @@ public function setUp()
);
}

/**
* Note that this test intentionally hardcodes the available dimensions so
* that we can confirm that the dimensions are all present and correct for
* fresh installs and for upgrades. Needless to say, the expected results
* must be updated when the SUPReMM schema changes.
*/
public function testDimensions()
{
$this->xdmodhelper->authenticate("cd");
$queryparams = array(
'realm' => 'SUPREMM'
);
$response = $this->xdmodhelper->get($this->endpoint . 'dimensions', $queryparams);

$this->assertEquals(200, $response[1]['http_code']);

$resdata = $response[0];

$this->assertArrayHasKey('success', $resdata);
$this->assertEquals(true, $resdata['success']);

$dimids = array();
foreach ($resdata['results'] as $dimension) {
$dimids[] = $dimension['id'];
}

$expectedDimensions = <<<EOF
[
"application",
"catastrophe_bucket_id",
"cpi",
"cpucv",
"cpuuser",
"datasource",
"nsfdirectorate",
"parentscience",
"exit_status",
"netdrv_gpfs_rx_bucket_id",
"grant_type",
"granted_pe",
"ibrxbyterate_bucket_id",
"netdrv_isilon_rx_bucket_id",
"jobsize",
"jobwalltime",
"nodecount",
"netdrv_panasas_rx_bucket_id",
"max_mem",
"pi",
"fieldofscience",
"pi_institution",
"queue",
"resource",
"provider",
"shared",
"username",
"person",
"institution"
]
EOF;
$this->assertEquals(json_decode($expectedDimensions, true), $dimids);

$this->xdmodhelper->logout();
}


public function testResourceEndPoint()
{
$this->xdmodhelper->authenticate("cd");
Expand All @@ -42,10 +107,18 @@ public function testResourceEndPoint()
$this->assertArrayHasKey('short_name', $resource);
$this->assertArrayHasKey('long_name', $resource);
}

$this->xdmodhelper->logout();
}

public function testResourceNoAuth()
{
$queryparams = array(
'realm' => 'SUPREMM'
);
$response = $this->xdmodhelper->get($this->endpoint . 'dimensions/resource', $queryparams);

$this->assertEquals(401, $response[1]['http_code']);
}

private function validateSingleJobSearch($searchparams)
Expand All @@ -63,9 +136,45 @@ private function validateSingleJobSearch($searchparams)
$this->assertArrayHasKey('dtype', $jobdata);
$this->assertArrayHasKey($jobdata['dtype'], $jobdata);

$this->xdmodhelper->logout();

return $jobdata;
}

public function testBasicJobSearch() {
$queryparams = array(
'realm' => 'SUPREMM',
'params' => json_encode(
array(
'resource_id' => 5,
'local_job_id' => 6117153
)
)
);
$this->validateSingleJobSearch($queryparams);
}

public function testBasicJobSearchNoAuth() {
$searchparams = array(
'realm' => 'SUPREMM',
'params' => json_encode(
array(
'resource_id' => 5,
'local_job_id' => 6117153
)
)
);

foreach (array('usr', 'pi') as $unpriv) {
$this->xdmodhelper->authenticate($unpriv);
$response = $this->xdmodhelper->get($this->endpoint . 'search/jobs', $searchparams);
$this->assertEquals(403, $response[1]['http_code']);
$this->assertArrayHasKey('success', $response[0]);
$this->assertEquals(false, $response[0]['success']);
$this->xdmodhelper->logout();
}
}

public function testInvalidJobSearch() {

$this->xdmodhelper->authenticate("cd");
Expand All @@ -74,6 +183,8 @@ public function testInvalidJobSearch() {
$this->assertArrayHasKey('success', $result[0]);
$this->assertEquals($result[0]['success'], false);
$this->assertEquals($result[1]['http_code'], 400);

$this->xdmodhelper->logout();
}

public function testInvalidJobSearchJson() {
Expand All @@ -89,6 +200,8 @@ public function testInvalidJobSearchJson() {
$this->assertArrayHasKey('success', $result[0]);
$this->assertEquals($result[0]['success'], false);
$this->assertEquals($result[1]['http_code'], 400);

$this->xdmodhelper->logout();
}

public function testInvalidJobSearchMissingParams() {
Expand All @@ -104,6 +217,8 @@ public function testInvalidJobSearchMissingParams() {
$this->assertArrayHasKey('success', $result[0]);
$this->assertEquals($result[0]['success'], false);
$this->assertEquals($result[1]['http_code'], 400);

$this->xdmodhelper->logout();
}

public function testAdvancedSearchInvalid() {
Expand All @@ -123,5 +238,7 @@ public function testAdvancedSearchInvalid() {
$result = $this->xdmodhelper->get($this->endpoint . 'search/jobs', $searchparams);
$this->assertEquals($result[0]['success'], false);
$this->assertEquals($result[1]['http_code'], 400);

$this->xdmodhelper->logout();
}
}

0 comments on commit 8fa9633

Please sign in to comment.