Created
December 30, 2019 16:12
-
-
Save gnschenker/e46e1cc6c5ad0e96470de8d2704e7296 to your computer and use it in GitHub Desktop.
Using the getToken util function to retrieve the bearer token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Suite to test the glossary API", () => { | |
const uuidv1 = require('uuid/v1'); | |
const https = require('https'); | |
const httpsAgent = new https.Agent({ rejectUnauthorized: false }); | |
const axios = require('axios'); | |
const host = process.env.API_HOST || "localhost"; | |
const baseUrl = `http://${host}:5000/api`; | |
console.log(`BaseURL: ${baseUrl}`); | |
const client = axios.create({ | |
baseURL: baseUrl, | |
httpsAgent | |
}) | |
const utils = require('./utils.js'); | |
var token = ""; | |
var headers = ""; | |
beforeAll(async () => { | |
token = await utils.getToken(); | |
headers = { | |
"Authorization": "Bearer " + token, | |
"Content-Type": "application/json" | |
} | |
}); | |
describe("when calling /glossary", () => { | |
it("should return list of glossaries", async () => { | |
const response = await client.get('glossary'); | |
expect(response.status).toBe(200); | |
expect(response.data.length).toBeGreaterThan(0); | |
expect(response.data[0].term).toBe('AccessToken'); | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment