const res = await request(reporter.server).get("/metrics").set("Accept-Encoding", "none"); expect(res.statusCode).toBe(200); expect(res.headers["content-type"]).toBe("text/plain; version=0.0.4; charset=utf-8"); expect(res.text).toBe("Fake generatePrometheusResponse content."); expect(res.headers["content-type"]).toBe("text/plain; version=0.0.4; charset=utf-8"); expect(res.headers["content-encoding"]).toBe("gzip"); expect(res.text).toBe("Fake generatePrometheusResponse content.");
context('#express with debug set to true and has empty intents', function() { beforeEach(function() { testApp.intent('emptyIntent'); testApp.express({ expressApp: app, checkCert: false, debug: true }); }); it('returns no utterances', function() { return request(testServer) .get('/testApp?utterances') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(''); }); }); });
.get('/testApp?schema') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(testApp.schema()); });
.get('/testApp?schema') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(testApp.schema()); }); .get('/testApp?schema&schemaType=skillBuilder') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(testApp.schemas.skillBuilder()); }); .get('/testApp?schema&schemaType=invalid') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(''); }); .get('/testApp?utterances') .expect(200).then(function(response) { expect(response.headers['content-type']).to.equal('text/plain; charset=utf-8'); expect(response.text).to.eq(testApp.utterances()); });
it('(cache created 3) GET /users/cache - 200', async () => { return request(gateway) .get('/users/cache') .expect(200) .then((response) => { expect(response.headers['x-cache-hit']).to.equal(undefined) }) })
describe('CSRF ROUTE', () => { test('Attempt to obtain CSRF token - GET '.concat(config.routes.csrf), async () => { const response = await request.get(config.routes.csrf).expect('set-cookie', /connect.sid/); session_cookie = response.headers['set-cookie']; csrf_token = response.body._csrf; assert.equal(response.statusCode, 200); }); });
it('should redirect to callback url with an error and keeping state when calling authorize endpoint with an invalid response type', async () => { const res = await request(service.requestHandler) .get('/authorize') .query('response_type=invalid_response_type&redirect_uri=http://example.com/callback&scope=dummy_scope&state=state123&client_id=abcecedf') .redirects(0) .expect(302); expect(res.headers.location).toMatch('http://example.com/callback?error=unsupported_response_type&error_description=The+authorization+server+does+not+support+obtaining+an+access+token+using+this+response_type.&state=state123'); });
test('Test OPTIONS request', async (done) => { const RANDOM_ORIGIN = `https://${Math.random()}.random` const res = await request(app).options('/get').set('Origin', RANDOM_ORIGIN) expect(res.statusCode).toBe(200) // 'cause we accept requests from allOrigins :D expect(res.headers['access-control-allow-origin']).toBe(RANDOM_ORIGIN) expect(res.headers['access-control-allow-methods']).toBe('OPTIONS, GET, POST, PATCH, PUT, DELETE') expect(res.body.contents).toBeUndefined() done() })
it('should expose CORS headers in an OPTIONS request', async () => { const res = await request(service.requestHandler) .options('/token') .expect(204); expect(res.headers['access-control-allow-origin']).toBe('*'); });
it('search challenges successfully 2', async () => { const response = await chai.request(app) .get(basePath) .set('Authorization', `Bearer ${config.M2M_FULL_ACCESS_TOKEN}`) .query({ name: 'xxjklsdjfihx' }) should.equal(response.status, 200) should.equal(response.headers['x-page'], '1') should.equal(response.headers['x-per-page'], '20') should.equal(response.headers['x-total'], '0') should.equal(response.headers['x-total-pages'], '0') should.equal(response.body.length, 0) })
it('(aggregation cache created after expire) GET /users/proxy-aborted/info - 200', (done) => { setTimeout(() => { request(gateway) .get('/users/proxy-aborted/info') .expect(200) .then((response) => { expect(response.text).to.equal('Hello World!') expect(response.headers['x-cache-hit']).to.equal(undefined) done() }) }, 1100) })
it('(aggregation cache hit) GET /users/proxy-aborted/info - 200', async () => { await request(gateway) .get('/users/proxy-aborted/info') .expect(200) .then((response) => { expect(response.text).to.equal('Hello World!') expect(response.headers['x-cache-hit']).to.equal('1') }) })
it('(cache hit) GET /users/cache - 200', async () => { await request(gateway) .get('/users/cache') .expect(200) .then((response) => { expect(response.headers['x-cache-hit']).to.equal('1') expect(typeof response.body.time).to.equal('number') }) })
it('(cache created 1) GET /users/cache - 200', async () => { await request(gateway) .get('/users/cache') .expect(200) .then((response) => { expect(response.headers['x-cache-hit']).to.equal(undefined) expect(typeof response.body.time).to.equal('number') }) })
it('(cache created 2) GET /users/cache - 200', async () => { return request(gateway) .get('/users/cache') .expect(200) .then((response) => { expect(response.headers['x-cache-hit']).to.equal(undefined) }) })