it('should support global request params', async () => {
   const google = new GoogleApis();
   google.options({params: {myParam: '123'}});
   const drive = google.drive('v2');
   nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
   const res = await drive.files.get({fileId: '123'});
   // If the default param handling is broken, query might be undefined, thus
   // concealing the assertion message with some generic "cannot call
   // .indexOf of undefined"
   let query = Utils.getQs(res) || '';
   assert.notEqual(
       query.indexOf('myParam=123'), -1, 'Default param not found in query');
   // I can't explain why, but the `nock.enableNetConnect()` call below simply
   // won't work unless I call `nock.cleanAll()` first.
   nock.cleanAll();
   nock.enableNetConnect();
   const d = await Utils.loadApi(google, 'drive', 'v2');
   nock.disableNetConnect();
   nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
   // tslint:disable-next-line no-any
   const res3 = await (d as any).files.get({fileId: '123'});
   // If the default param handling is broken, query might be undefined,
   // thus concealing the assertion message with some generic "cannot
   // call .indexOf of undefined"
   query = Utils.getQs(res3) || '';
   assert.notEqual(
       query.indexOf('myParam=123'), -1, 'Default param not found in query');
 });
 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localPlus = google.plus('v1');
   localOauth2 = google.oauth2('v2');
 });
 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localDrive = google.drive('v2');
   localUrlshortener = google.urlshortener('v1');
 });
 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   remoteDrive = await Utils.loadApi(google, 'drive', 'v2');
   nock.disableNetConnect();
 });
 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localDrive = google.drive('v2');
   localGmail = google.gmail('v1');
 });
Ejemplo n.º 6
0
 afterEach(() => {
   if (!nock.isDone()) {
     // tslint:disable-next-line
     console.error('nock is not done', nock.pendingMocks());
   }
   nock.cleanAll();
 });
 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   remoteUrlshortener = await Utils.loadApi(google, 'urlshortener', 'v1');
   nock.disableNetConnect();
 });
Ejemplo n.º 8
0
 afterEach(() => {
   sandbox.verifyAndRestore();
   if (!nock.isDone()) {
     // tslint:disable-next-line
     console.error('nock is not done', nock.pendingMocks());
   }
   nock.cleanAll();
 });
Ejemplo n.º 9
0
 afterEach(function (done) {
     process.env.SKIP_STATISTICS = "true";
     nock.cleanAll();
     if (!nock.isActive()) {
         nock.activate();
     }
     done();
 });
  it('should redirect to access denied page when user not in required role', async () => {
    mock.cleanAll()
    idamServiceMock.resolveRetrieveUserFor('1', 'divorce-private-beta')

    await request.agent(app)[method](pagePath)
      .set('Cookie', `${cookieName}=ABC`)
      .expect(res => expect(res).redirect.toLocation(accessDeniedPage))
  })