Skip to content

Commit 5a9fa44

Browse files
committed
fix metadata test after SF update
1 parent 2b4016c commit 5a9fa44

1 file changed

Lines changed: 61 additions & 48 deletions

File tree

tests/Common/MetadataTest.php

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
class MetadataTest extends StorageApiTestCase
2121
{
2222
use MetadataUtils;
23-
const TEST_PROVIDER = 'test';
2423

24+
const TEST_PROVIDER = 'test';
2525
const TEST_METADATA_KEY_1 = 'test_metadata_key1';
2626
const TEST_METADATA_KEY_2 = 'test_metadata_key2';
27-
2827
const ISO8601_REGEXP = '/^([0-9]{4})-(1[0-2]|0[1-9])-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\+([0-9]{4})$/';
2928
// constants used for data providers in order to run it on all endpoints but also represents part of URL
3029
const ENDPOINT_TYPE_COLUMNS = 'columns';
@@ -64,7 +63,7 @@ public function setUp(): void
6463
$this->_testClient->createTableAsync($this->getTestBucketId(), 'test_table', new CsvFile(__DIR__ . '/../_data/users.csv'));
6564
}
6665

67-
/**
66+
/**
6867
* @dataProvider provideComponentsClientTypeBasedOnSuite
6968
* @group SOX-66
7069
*/
@@ -208,7 +207,7 @@ public function testColumnMetadataOverwrite(string $devBranchType, string $userR
208207
$this->assertSame($metadata[0]['value'], 'testValue');
209208
}
210209

211-
/**
210+
/**
212211
* @dataProvider provideComponentsClientTypeBasedOnSuite
213212
* @group SOX-66
214213
*/
@@ -281,7 +280,7 @@ public function testTableMetadata(string $devBranchType, string $userRole): void
281280
/**
282281
* @return void
283282
*/
284-
/**
283+
/**
285284
* @dataProvider provideComponentsClientTypeBasedOnSuite
286285
* @group SOX-66
287286
*/
@@ -405,7 +404,7 @@ public function testTableMetadataWithColumns(string $devBranchType, string $user
405404
}
406405
}
407406

408-
/**
407+
/**
409408
* @dataProvider provideComponentsClientTypeBasedOnSuite
410409
* @group SOX-66
411410
*/
@@ -447,10 +446,14 @@ public function testColumnMetadataWithColumnsWithIntegers(string $devBranchType,
447446
$this->assertArrayEqualsExceptKeys($mdForTable, $tableDetail['metadata'][0], ['id', 'provider', 'timestamp']);
448447

449448
$this->assertCount(1, $tableDetail['columnMetadata']);
450-
$this->assertArrayEqualsExceptKeys($mdForColumn, $tableDetail['columnMetadata'][0][0], ['id', 'provider', 'timestamp']);
449+
$this->assertArrayEqualsExceptKeys($mdForColumn, $tableDetail['columnMetadata'][0][0], [
450+
'id',
451+
'provider',
452+
'timestamp',
453+
]);
451454
}
452455

453-
/**
456+
/**
454457
* @dataProvider provideComponentsClientTypeBasedOnSuite
455458
* @group SOX-66
456459
*/
@@ -541,7 +544,7 @@ public function testTableMetadataWithColumnsWithIntegers(string $devBranchType,
541544
$this->assertEquals(self::TEST_PROVIDER, $metadata[0]['provider']);
542545
}
543546

544-
/**
547+
/**
545548
* @dataProvider provideComponentsClientTypeBasedOnSuite
546549
* @group SOX-66
547550
*/
@@ -632,7 +635,7 @@ public function testTableMetadataForTokenWithReadPrivilege(string $devBranchType
632635
$this->assertCount(1, $metadataArray);
633636
}
634637

635-
/**
638+
/**
636639
* @dataProvider provideComponentsClientTypeBasedOnSuite
637640
* @group SOX-66
638641
*/
@@ -677,7 +680,7 @@ public function testTableDeleteWithMetadata(string $devBranchType, string $userR
677680
$metadataApi->listTableMetadata($columnId);
678681
}
679682

680-
/**
683+
/**
681684
* @dataProvider provideComponentsClientTypeBasedOnSuite
682685
* @group SOX-66
683686
*/
@@ -786,7 +789,7 @@ public function testColumnMetadata(string $devBranchType, string $userRole): voi
786789
);
787790
}
788791

789-
/**
792+
/**
790793
* @dataProvider provideComponentsClientTypeBasedOnSuite
791794
* @group SOX-66
792795
*/
@@ -877,7 +880,7 @@ public function testColumnMetadataForTokenWithReadPrivilege(string $devBranchTyp
877880
$this->assertCount(1, $metadataArray);
878881
}
879882

880-
/**
883+
/**
881884
* @dataProvider provideComponentsClientTypeBasedOnSuite
882885
* @group SOX-66
883886
*/
@@ -911,15 +914,15 @@ public function testTableColumnDeleteWithMetadata(string $devBranchType, string
911914
$tableDetail = $this->_testClient->getTable($tableId);
912915
$this->assertEmpty($tableDetail['columnMetadata']);
913916

914-
$this->assertEquals(['id','name','city'], $tableDetail['columns']);
917+
$this->assertEquals(['id', 'name', 'city'], $tableDetail['columns']);
915918

916919
$this->expectException(ClientException::class);
917920
$this->expectExceptionCode(404);
918921

919922
$metadataApi->listColumnMetadata($columnId);
920923
}
921924

922-
/**
925+
/**
923926
* @dataProvider provideComponentsClientTypeBasedOnSuite
924927
* @group SOX-66
925928
*/
@@ -1025,8 +1028,12 @@ public function testInvalidMetadata(string $devBranchType, string $userRole, $ap
10251028
* @dataProvider apiEndpoints
10261029
* @group SOX-66
10271030
*/
1028-
public function testInvalidMetadataWhenMetadataIsNotArray(string $devBranchType, string $userRole, $apiEndpoint, $object): void
1029-
{
1031+
public function testInvalidMetadataWhenMetadataIsNotArray(
1032+
string $devBranchType,
1033+
string $userRole,
1034+
$apiEndpoint,
1035+
$object
1036+
): void {
10301037
$bucketId = self::getTestBucketId();
10311038
$objectId = $bucketId . $object;
10321039

@@ -1047,8 +1054,12 @@ public function testInvalidMetadataWhenMetadataIsNotArray(string $devBranchType,
10471054
* @dataProvider apiEndpoints
10481055
* @group SOX-66
10491056
*/
1050-
public function testInvalidMetadataWhenMetadataIsNotPresent(string $devBranchType, string $userRole, $apiEndpoint, $object): void
1051-
{
1057+
public function testInvalidMetadataWhenMetadataIsNotPresent(
1058+
string $devBranchType,
1059+
string $userRole,
1060+
$apiEndpoint,
1061+
$object
1062+
): void {
10521063
$bucketId = self::getTestBucketId();
10531064
$objectId = $bucketId . $object;
10541065

@@ -1069,7 +1080,7 @@ public function testInvalidMetadataWhenMetadataIsNotPresent(string $devBranchTyp
10691080
*/
10701081
public function testMetadata40xs(string $devBranchType, string $userRole, $apiEndpoint, $object): void
10711082
{
1072-
$bucketId = self::getTestBucketId();
1083+
$bucketId = $this->getTestBucketId();
10731084
$object = ($apiEndpoint === 'bucket') ? $bucketId : $bucketId . $object;
10741085

10751086
// test invalid number
@@ -1079,34 +1090,36 @@ public function testMetadata40xs(string $devBranchType, string $userRole, $apiEn
10791090
} catch (ClientException $e) {
10801091
$this->assertEquals(404, $e->getCode());
10811092
$this->assertEquals('storage.metadata.notFound', $e->getStringCode());
1082-
$this->assertEquals('The supplied metadata ID was not found', $e->getMessage());
1093+
$this->assertEquals(sprintf('Metadata "9999999" not found for bucket "%s".', $this->getTestBucketId()), $e->getMessage());
10831094
}
10841095

10851096
// test null
1086-
try {
1087-
$this->deleteMetadata($apiEndpoint, $object, null);
1088-
$this->fail('Invalid metadataId');
1089-
} catch (ClientException $e) {
1090-
$this->assertEquals(400, $e->getCode());
1091-
$this->assertEquals('APPLICATION_ERROR', $e->getStringCode());
1092-
$this->assertEquals('exceptions.storage.metadata.invalidDelete', $e->getMessage());
1093-
}
1094-
1095-
// not numeric value
1096-
try {
1097-
$this->deleteMetadata($apiEndpoint, $object, 'notNumber');
1098-
$this->fail('Invalid metadataId');
1099-
} catch (ClientException $e) {
1100-
$this->assertEquals(400, $e->getCode());
1101-
$this->assertEquals('APPLICATION_ERROR', $e->getStringCode());
1102-
$this->assertEquals(
1103-
'Argument "subResource" is expected to be type "int", value "notNumber" given.',
1104-
$e->getMessage(),
1105-
);
1097+
if ($apiEndpoint !== 'buckets') {
1098+
// don't test this on migrated endpoint, this had an extra handling in zend, 404 is returned from Symfony
1099+
try {
1100+
$this->deleteMetadata($apiEndpoint, $object, null);
1101+
$this->fail('Invalid metadataId');
1102+
} catch (ClientException $e) {
1103+
$this->assertEquals(400, $e->getCode());
1104+
$this->assertEquals('APPLICATION_ERROR', $e->getStringCode());
1105+
$this->assertEquals('exceptions.storage.metadata.invalidDelete', $e->getMessage());
1106+
}
1107+
// not numeric value
1108+
try {
1109+
$this->deleteMetadata($apiEndpoint, $object, 'notNumber');
1110+
$this->fail('Invalid metadataId');
1111+
} catch (ClientException $e) {
1112+
$this->assertEquals(400, $e->getCode());
1113+
$this->assertEquals('APPLICATION_ERROR', $e->getStringCode());
1114+
$this->assertEquals(
1115+
'Argument "subResource" is expected to be type "int", value "notNumber" given.',
1116+
$e->getMessage(),
1117+
);
1118+
}
11061119
}
11071120
}
11081121

1109-
/**
1122+
/**
11101123
* @dataProvider provideComponentsClientTypeBasedOnSuite
11111124
* @group SOX-66
11121125
*/
@@ -1138,7 +1151,7 @@ public function testInvalidProvider(string $devBranchType, string $userRole): vo
11381151
}
11391152
}
11401153

1141-
/**
1154+
/**
11421155
* @dataProvider provideComponentsClientTypeBasedOnSuite
11431156
* @group SOX-66
11441157
*/
@@ -1154,11 +1167,11 @@ public function testTryToRemoveForeignData(string $devBranchType, string $userRo
11541167
$anotherBucketId = $this->getTestBucketId(self::STAGE_OUT);
11551168

11561169
$this->expectException(ClientException::class);
1157-
$this->expectExceptionMessage('The supplied metadata ID was not found');
1170+
$this->expectExceptionMessage(sprintf('Metadata "%s" not found for bucket "%s".', $createdMetadata[0]['id'], $anotherBucketId));
11581171
$medataApi->deleteBucketMetadata($anotherBucketId, $createdMetadata[0]['id']);
11591172
}
11601173

1161-
/**
1174+
/**
11621175
* @dataProvider provideComponentsClientTypeBasedOnSuite
11631176
* @group SOX-66
11641177
*/
@@ -1174,11 +1187,11 @@ public function testTryToRemoveForeignMetadataFromTable(string $devBranchType, s
11741187
$createdMetadata = $medataApi->postTableMetadata($tableId, 'provider', [$md]);
11751188

11761189
$this->expectException(ClientException::class);
1177-
$this->expectExceptionMessage('The supplied metadata ID was not found');
1190+
$this->expectExceptionMessage(sprintf('Metadata "%s" not found for bucket "%s".', $createdMetadata[0]['id'], $this->getTestBucketId()));
11781191
$medataApi->deleteBucketMetadata($this->getTestBucketId(), $createdMetadata[0]['id']);
11791192
}
11801193

1181-
/**
1194+
/**
11821195
* @dataProvider provideComponentsClientTypeBasedOnSuite
11831196
* @group SOX-66
11841197
*/
@@ -1341,7 +1354,7 @@ private function getMetadataTestColumnId($tableId, $columnId)
13411354
return sprintf('%s.%s.%s', $this->getTestBucketId(), $tableId, $columnId);
13421355
}
13431356

1344-
/**
1357+
/**
13451358
* @dataProvider provideComponentsClientTypeBasedOnSuite
13461359
* @group SOX-66
13471360
*/

0 commit comments

Comments
 (0)