@@ -205,7 +205,7 @@ describe('AWS.S3Control', function() {
205205 } ) ;
206206 } ) ;
207207
208- it ( 'should correctly generate access point endpoint for pseudo regions ' , function ( ) {
208+ it ( 'should correctly generate access point endpoint for s3-external-1 ' , function ( ) {
209209 var client = new AWS . S3Control ( { region : 'us-east-1' } ) ;
210210 helpers . mockHttpResponse ( 200 , { } , '' ) ;
211211 var request = client . getBucket ( {
@@ -215,22 +215,32 @@ describe('AWS.S3Control', function() {
215215 expect (
216216 built . httpRequest . endpoint . hostname
217217 ) . to . equal ( 's3-outposts.s3-external-1.amazonaws.com' ) ;
218+ } ) ;
218219
219- var testFipsError = ( client ) => {
220- helpers . mockHttpResponse ( 200 , { } , '' ) ;
221- request = client . getBucket ( {
222- Bucket : 'arn:aws:s3-outposts:s3-external-1:123456789012:outpost/op-01234567890123456/bucket/mybucket'
223- } ) ;
224- var error ;
225- request . build ( function ( err ) {
226- error = err ;
227- } ) ;
228- expect ( error . name ) . to . equal ( 'InvalidConfiguration' ) ;
229- expect ( error . message ) . to . equal ( 'ARN endpoint is not compatible with FIPS region' ) ;
230- } ;
231- testFipsError ( new AWS . S3Control ( { region : 'fips-us-east-1' } ) ) ;
232- testFipsError ( new AWS . S3Control ( { region : 'us-east-1-fips' } ) ) ;
233- testFipsError ( new AWS . S3Control ( { region : 'us-east-1' , useFipsEndpoint : true } ) ) ;
220+ it ( 'should correctly generate access point endpoint when useFipsEndpoint=true' , function ( ) {
221+ var client = new AWS . S3Control ( { region : 'us-gov-west-1' , useFipsEndpoint : true } ) ;
222+ helpers . mockHttpResponse ( 200 , { } , '' ) ;
223+ var request = client . getBucket ( {
224+ Bucket : 'arn:aws:s3-outposts:us-gov-west-1:123456789012:outpost/op-01234567890123456/bucket/mybucket'
225+ } ) ;
226+ var built = request . build ( function ( ) { } ) ;
227+ expect (
228+ built . httpRequest . endpoint . hostname
229+ ) . to . equal ( 's3-outposts-fips.us-gov-west-1.amazonaws.com' ) ;
230+ } ) ;
231+
232+ it ( 'should throw when fips region is passed in ARN' , function ( ) {
233+ var client = new AWS . S3Control ( { region : 'us-gov-west-1' , useFipsEndpoint : true } ) ;
234+ helpers . mockHttpResponse ( 200 , { } , '' ) ;
235+ var request = client . getBucket ( {
236+ Bucket : 'arn:aws:s3-outposts:fips-us-gov-west-1:123456789012:outpost/op-01234567890123456/bucket/mybucket'
237+ } ) ;
238+ var error ;
239+ request . build ( function ( err ) {
240+ error = err ;
241+ } ) ;
242+ expect ( error . name ) . to . equal ( 'InvalidConfiguration' ) ;
243+ expect ( error . message ) . to . equal ( 'FIPS region not allowed in ARN' ) ;
234244 } ) ;
235245
236246 it ( 'should use regions from ARN if s3UseArnRegion config is set to false' , function ( done ) {
0 commit comments