@@ -20,6 +20,32 @@ describe("config", function () {
2020 cloudinary . config ( true ) ;
2121 } ) ;
2222
23+ it ( "should support `hide_sensitive` config param" , function ( ) {
24+ const config = cloudinary . config ( { hide_sensitive : true } ) ;
25+ expect ( config . hide_sensitive ) . to . eql ( true )
26+ } ) ;
27+
28+ it ( "should hide API key and secret upon error when `hide_sensitive` is true" , async function ( ) {
29+ try {
30+ cloudinary . config ( { hide_sensitive : true } ) ;
31+ const result = await cloudinary . v2 . api . resource ( "?" ) ;
32+ expect ( result ) . fail ( ) ;
33+ } catch ( err ) {
34+ console . log ( err . request_options ) ;
35+ expect ( err . request_options ) . not . to . have . property ( "auth" ) ;
36+ }
37+ } ) ;
38+
39+ it ( "should hide Authorization header upon error when `hide_sensitive` is true" , async function ( ) {
40+ try {
41+ cloudinary . config ( { hide_sensitive : true } ) ;
42+ const result = await cloudinary . v2 . api . resource ( "?" , { oauth_token : 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI4' } ) ;
43+ expect ( result ) . fail ( ) ;
44+ } catch ( err ) {
45+ console . log ( err . request_options ) ;
46+ expect ( err . request_options . headers ) . not . to . have . property ( "Authorization" ) ;
47+ }
48+ } ) ;
2349
2450 it ( "should allow nested values in CLOUDINARY_URL" , function ( ) {
2551 process . env . CLOUDINARY_URL = "cloudinary://key:secret@test123?foo[bar]=value" ;
@@ -97,33 +123,4 @@ describe("config", function () {
97123 const config = cloudinary . config ( { api_proxy : proxy } ) ;
98124 expect ( config . api_proxy ) . to . eql ( proxy )
99125 } ) ;
100-
101- it ( "should support `hide_sensitive` config param" , function ( ) {
102- const config = cloudinary . config ( { hide_sensitive : true } ) ;
103- expect ( config . hide_sensitive ) . to . eql ( true )
104- } ) ;
105-
106- it . only ( "should hide API key and secret upon error when `hide_sensitive` is true" , async function ( ) {
107- cloudinary . config ( { hide_sensitive : true } ) ;
108-
109- try {
110- const result = await cloudinary . v2 . api . resource ( "?" ) ;
111- expect ( result ) . fail ( ) ;
112- } catch ( err ) {
113- console . log ( err . request_options ) ;
114- expect ( err . request_options ) . not . to . have . property ( "auth" ) ;
115- }
116- } ) ;
117-
118- it . only ( "should hide Authorization header upon error when `hide_sensitive` is true" , async function ( ) {
119- cloudinary . config ( { hide_sensitive : true } ) ;
120-
121- try {
122- const result = await cloudinary . v2 . api . resource ( "?" , { oauth_token : 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI4' } ) ;
123- expect ( result ) . fail ( ) ;
124- } catch ( err ) {
125- console . log ( err . request_options ) ;
126- expect ( err . request_options . headers ) . not . to . have . property ( "Authorization" ) ;
127- }
128- } ) ;
129126} ) ;
0 commit comments