@@ -12,47 +12,52 @@ describe('parseAttributesHeaders', () => {
1212 err => {
1313 assert ( err . is ) ;
1414 assert . strictEqual ( err . is . InvalidRequest , true ) ;
15- assert ( err . description . includes ( 'missing or empty' ) ) ;
15+ assert . strictEqual (
16+ err . description ,
17+ 'The x-amz-object-attributes header specifying the attributes to be retrieved is either missing or empty' ,
18+ ) ;
1619 return true ;
1720 } ,
1821 ) ;
1922 } ) ;
2023
21- it ( 'should throw InvalidRequest error when header is empty string' , ( ) => {
24+ it ( 'should throw InvalidArgument error when header is empty string' , ( ) => {
2225 const headers = { 'x-amz-object-attributes' : '' } ;
2326
2427 assert . throws (
2528 ( ) => parseAttributesHeaders ( headers ) ,
2629 err => {
2730 assert ( err . is ) ;
28- assert . strictEqual ( err . is . InvalidRequest , true ) ;
29- assert ( err . description . includes ( 'missing or empty' ) ) ;
31+ assert . strictEqual ( err . is . InvalidArgument , true ) ;
32+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
3033 return true ;
3134 } ,
3235 ) ;
3336 } ) ;
3437
35- it ( 'should throw InvalidRequest error when header contains only whitespace' , ( ) => {
38+ it ( 'should throw InvalidArgument error when header contains only whitespace' , ( ) => {
3639 const headers = { 'x-amz-object-attributes' : ' ' } ;
3740
3841 assert . throws (
3942 ( ) => parseAttributesHeaders ( headers ) ,
4043 err => {
4144 assert ( err . is ) ;
42- assert . strictEqual ( err . is . InvalidRequest , true ) ;
45+ assert . strictEqual ( err . is . InvalidArgument , true ) ;
46+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
4347 return true ;
4448 } ,
4549 ) ;
4650 } ) ;
4751
48- it ( 'should throw InvalidRequest error when header contains only commas' , ( ) => {
52+ it ( 'should throw InvalidArgument error when header contains only commas' , ( ) => {
4953 const headers = { 'x-amz-object-attributes' : ',,,' } ;
5054
5155 assert . throws (
5256 ( ) => parseAttributesHeaders ( headers ) ,
5357 err => {
5458 assert ( err . is ) ;
55- assert . strictEqual ( err . is . InvalidRequest , true ) ;
59+ assert . strictEqual ( err . is . InvalidArgument , true ) ;
60+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
5661 return true ;
5762 } ,
5863 ) ;
@@ -68,7 +73,7 @@ describe('parseAttributesHeaders', () => {
6873 err => {
6974 assert ( err . is ) ;
7075 assert . strictEqual ( err . is . InvalidArgument , true ) ;
71- assert ( err . description . includes ( 'Invalid attribute name' ) ) ;
76+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
7277 return true ;
7378 } ,
7479 ) ;
@@ -82,6 +87,7 @@ describe('parseAttributesHeaders', () => {
8287 err => {
8388 assert ( err . is ) ;
8489 assert . strictEqual ( err . is . InvalidArgument , true ) ;
90+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
8591 return true ;
8692 } ,
8793 ) ;
@@ -95,6 +101,7 @@ describe('parseAttributesHeaders', () => {
95101 err => {
96102 assert ( err . is ) ;
97103 assert . strictEqual ( err . is . InvalidArgument , true ) ;
104+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
98105 return true ;
99106 } ,
100107 ) ;
@@ -173,20 +180,32 @@ describe('parseAttributesHeaders', () => {
173180 assert . deepStrictEqual ( result , [ 'ETag' , 'ObjectSize' ] ) ;
174181 } ) ;
175182
176- it ( 'should handle extra commas between attributes' , ( ) => {
183+ it ( 'should throw InvalidArgument for extra commas between attributes' , ( ) => {
177184 const headers = { 'x-amz-object-attributes' : 'ETag,,ObjectSize' } ;
178- const result = parseAttributesHeaders ( headers ) ;
179185
180- assert ( Array . isArray ( result ) ) ;
181- assert . deepStrictEqual ( result , [ 'ETag' , 'ObjectSize' ] ) ;
186+ assert . throws (
187+ ( ) => parseAttributesHeaders ( headers ) ,
188+ err => {
189+ assert ( err . is ) ;
190+ assert . strictEqual ( err . is . InvalidArgument , true ) ;
191+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
192+ return true ;
193+ } ,
194+ ) ;
182195 } ) ;
183196
184- it ( 'should handle leading and trailing commas' , ( ) => {
197+ it ( 'should throw InvalidArgument for leading and trailing commas' , ( ) => {
185198 const headers = { 'x-amz-object-attributes' : ',ETag,ObjectSize,' } ;
186- const result = parseAttributesHeaders ( headers ) ;
187199
188- assert ( Array . isArray ( result ) ) ;
189- assert . deepStrictEqual ( result , [ 'ETag' , 'ObjectSize' ] ) ;
200+ assert . throws (
201+ ( ) => parseAttributesHeaders ( headers ) ,
202+ err => {
203+ assert ( err . is ) ;
204+ assert . strictEqual ( err . is . InvalidArgument , true ) ;
205+ assert . strictEqual ( err . description , 'Invalid attribute name specified.' ) ;
206+ return true ;
207+ } ,
208+ ) ;
190209 } ) ;
191210 } ) ;
192211} ) ;
0 commit comments