import { Cookie as ToughCookie } from 'tough-cookie' ; import { ObfuscationUtil } from './ObfuscationUtil' ; import type { AccessTokenData } from '../auth' ; describe ( 'ObfuscationUtil' , ( ) => { const accessTokenData = { access_token : 'iJCRCjc8oROO-dkrkqCXOade997oa8Jhbz6awMUQPBQo80VenWqp_oNvfY6AnU5BxEsdDPOBfBP-uz_b0gAKBQ==.v=1.k=1.d=1498600993.t=a.l=.u=aaf9a833-ef30-4c22-86a0-9adc8a15b3b4.c=15037015562284012115' , expires_in : 900 , token_type : 'Bearer' , user : 'aaf9a833-ef30-4c22-86a0-9adc8a15b3b4' , } ; const cookie = ToughCookie . parse ( 'zuid=SBMt4gP7v-SAxxP_8OEVVeTw11CeUBAV1Jx5AwdQNjcbgTIqvkhfmd8COLG5V3OrOJ==.v=1.k=1.d=1535117120.t=1234; Path=/access; Domain=example.com; HttpOnly; Secure' ) ; it ( 'obfuscates an access token' , ( ) => { const obfuscatedToken = ObfuscationUtil . obfuscateAccessToken ( accessTokenData ) ; expect ( obfuscatedToken . access_token ) . not . toBe ( accessTokenData . access_token ) ; } ) ; it ( `doesn't obfuscate an access token when disabled` , ( ) => { const obfuscatedToken = ObfuscationUtil . obfuscateAccessToken ( accessTokenData , false ) ; expect ( obfuscatedToken . access_token ) . toBe ( accessTokenData . access_token ) ; } ) ; it ( 'obfuscates a cookie' , ( ) => { if ( cookie ) { const obfuscatedCookie = ObfuscationUtil . obfuscateCookie ( cookie ) ; expect ( cookie . value ) . not . toBe ( obfuscatedCookie . value ) ; } } ) ; it ( `doesn't obfuscate a cookie when disabled` , ( ) => { if ( cookie ) { const obfuscatedCookie = ObfuscationUtil . obfuscateCookie ( cookie , false ) ; expect ( cookie . value ) . toBe ( obfuscatedCookie . value ) ; } } ) ; } ) ;