@@ -198,6 +198,7 @@ func TestParseVolumeARN(t *testing.T) {
198198 name string
199199 arn string
200200 expectError bool
201+ expectedPartition string
201202 expectedRegion string
202203 expectedAccountID string
203204 expectedFilesystemID string
@@ -207,6 +208,7 @@ func TestParseVolumeARN(t *testing.T) {
207208 name : "ValidARN" ,
208209 arn : testVolumeARN ,
209210 expectError : false ,
211+ expectedPartition : "aws" ,
210212 expectedRegion : "us-east-1" ,
211213 expectedAccountID : testAccountID ,
212214 expectedFilesystemID : testFilesystemID ,
@@ -236,6 +238,7 @@ func TestParseVolumeARN(t *testing.T) {
236238 name : "AWSChinaPartition" ,
237239 arn : "arn:aws-cn:fsx:cn-north-1:123456789012:volume/fs-1234567890abcdef0/fv-1234567890abcdef0" ,
238240 expectError : false ,
241+ expectedPartition : "aws-cn" ,
239242 expectedRegion : "cn-north-1" ,
240243 expectedAccountID : testAccountID ,
241244 expectedFilesystemID : testFilesystemID ,
@@ -245,16 +248,37 @@ func TestParseVolumeARN(t *testing.T) {
245248 name : "AWSGovCloudPartition" ,
246249 arn : "arn:aws-us-gov:fsx:us-gov-east-1:123456789012:volume/fs-1234567890abcdef0/fv-1234567890abcdef0" ,
247250 expectError : false ,
251+ expectedPartition : "aws-us-gov" ,
248252 expectedRegion : "us-gov-east-1" ,
249253 expectedAccountID : testAccountID ,
250254 expectedFilesystemID : testFilesystemID ,
251255 expectedVolumeID : testVolumeID ,
252256 },
257+ {
258+ name : "AWSTopSecretPartition" ,
259+ arn : "arn:aws-iso:fsx:us-iso-east-1:123456789012:volume/fs-1234567890abcdef0/fv-1234567890abcdef0" ,
260+ expectError : false ,
261+ expectedPartition : "aws-iso" ,
262+ expectedRegion : "us-iso-east-1" ,
263+ expectedAccountID : testAccountID ,
264+ expectedFilesystemID : testFilesystemID ,
265+ expectedVolumeID : testVolumeID ,
266+ },
267+ {
268+ name : "AWSSecretPartition" ,
269+ arn : "arn:aws-iso-b:fsx:us-iso-b-east-1:123456789012:volume/fs-1234567890abcdef0/fv-1234567890abcdef0" ,
270+ expectError : false ,
271+ expectedPartition : "aws-iso-b" ,
272+ expectedRegion : "us-iso-b-east-1" ,
273+ expectedAccountID : testAccountID ,
274+ expectedFilesystemID : testFilesystemID ,
275+ expectedVolumeID : testVolumeID ,
276+ },
253277 }
254278
255279 for _ , tt := range tests {
256280 t .Run (tt .name , func (t * testing.T ) {
257- region , accountID , filesystemID , volumeID , err := ParseVolumeARN (tt .arn )
281+ partition , region , accountID , filesystemID , volumeID , err := ParseVolumeARN (tt .arn )
258282
259283 if tt .expectError {
260284 assert .Error (t , err )
@@ -263,6 +287,7 @@ func TestParseVolumeARN(t *testing.T) {
263287 }
264288
265289 assert .NoError (t , err )
290+ assert .Equal (t , tt .expectedPartition , partition )
266291 assert .Equal (t , tt .expectedRegion , region )
267292 assert .Equal (t , tt .expectedAccountID , accountID )
268293 assert .Equal (t , tt .expectedFilesystemID , filesystemID )
@@ -276,6 +301,7 @@ func TestParseSecretARN(t *testing.T) {
276301 name string
277302 arn string
278303 expectError bool
304+ expectedPartition string
279305 expectedRegion string
280306 expectedAccountID string
281307 expectedSecretName string
@@ -284,6 +310,7 @@ func TestParseSecretARN(t *testing.T) {
284310 name : "ValidARN" ,
285311 arn : testSecretARN ,
286312 expectError : false ,
313+ expectedPartition : "aws" ,
287314 expectedRegion : "us-east-1" ,
288315 expectedAccountID : testAccountID ,
289316 expectedSecretName : testSecretName ,
@@ -312,15 +339,52 @@ func TestParseSecretARN(t *testing.T) {
312339 name : "SpecialCharacters" ,
313340 arn : "arn:aws:secretsmanager:us-east-1:123456789012:secret:my/secret_name.with+special@chars-AbCdEf" ,
314341 expectError : false ,
342+ expectedPartition : "aws" ,
315343 expectedRegion : "us-east-1" ,
316344 expectedAccountID : testAccountID ,
317345 expectedSecretName : "my/secret_name.with+special@chars" ,
318346 },
347+ {
348+ name : "AWSChinaPartition" ,
349+ arn : "arn:aws-cn:secretsmanager:cn-north-1:123456789012:secret:my/secret_name.with+special@chars-AbCdEf" ,
350+ expectError : false ,
351+ expectedPartition : "aws-cn" ,
352+ expectedRegion : "cn-north-1" ,
353+ expectedAccountID : testAccountID ,
354+ expectedSecretName : "my/secret_name.with+special@chars" ,
355+ },
356+ {
357+ name : "AWSGovCloudPartition" ,
358+ arn : "arn:aws-us-gov:secretsmanager:us-gov-east-1:123456789012:secret:my/secret_name.with+special@chars-AbCdEf" ,
359+ expectError : false ,
360+ expectedPartition : "aws-us-gov" ,
361+ expectedRegion : "us-gov-east-1" ,
362+ expectedAccountID : testAccountID ,
363+ expectedSecretName : "my/secret_name.with+special@chars" ,
364+ },
365+ {
366+ name : "AWSTopSecretPartition" ,
367+ arn : "arn:aws-iso:secretsmanager:us-iso-east-1:123456789012:secret:my/secret_name.with+special@chars-AbCdEf" ,
368+ expectError : false ,
369+ expectedPartition : "aws-iso" ,
370+ expectedRegion : "us-iso-east-1" ,
371+ expectedAccountID : testAccountID ,
372+ expectedSecretName : "my/secret_name.with+special@chars" ,
373+ },
374+ {
375+ name : "AWSSecretPartition" ,
376+ arn : "arn:aws-iso-b:secretsmanager:us-iso-b-east-1:123456789012:secret:my/secret_name.with+special@chars-AbCdEf" ,
377+ expectError : false ,
378+ expectedPartition : "aws-iso-b" ,
379+ expectedRegion : "us-iso-b-east-1" ,
380+ expectedAccountID : testAccountID ,
381+ expectedSecretName : "my/secret_name.with+special@chars" ,
382+ },
319383 }
320384
321385 for _ , tt := range tests {
322386 t .Run (tt .name , func (t * testing.T ) {
323- region , accountID , secretName , err := ParseSecretARN (tt .arn )
387+ partition , region , accountID , secretName , err := ParseSecretARN (tt .arn )
324388
325389 if tt .expectError {
326390 assert .Error (t , err )
@@ -329,6 +393,7 @@ func TestParseSecretARN(t *testing.T) {
329393 }
330394
331395 assert .NoError (t , err )
396+ assert .Equal (t , tt .expectedPartition , partition )
332397 assert .Equal (t , tt .expectedRegion , region )
333398 assert .Equal (t , tt .expectedAccountID , accountID )
334399 assert .Equal (t , tt .expectedSecretName , secretName )
0 commit comments