import * as assert from 'assert' ; import { describe , it , beforeEach , afterEach } from 'mocha' ; import * as sinon from 'sinon' ; import { IAMAuth } from '../src' ; describe ( 'iam' , ( ) => { const testSelector = 'a-test-selector' ; const testToken = 'a-test-token' ; let sandbox ; let client ; beforeEach ( ( ) => { sandbox = sinon . createSandbox ( ) ; client = new IAMAuth ( testSelector , testToken ) ; } ) ; afterEach ( ( ) => { sandbox . restore ( ) ; } ) ; it ( 'passes the token and selector to the callback ' , async ( ) => { const creds = client . getRequestHeaders ( ) ; assert . notStrictEqual ( creds , null , 'metadata should be present' ) ; assert . strictEqual ( creds ! [ 'x-goog-iam-authority-selector' ] , testSelector ) ; assert . strictEqual ( creds ! [ 'x-goog-iam-authorization-token' ] , testToken ) ; } ) ; } ) ;