Skip to content

Commit 908c0c8

Browse files
#388 update test config and user config to v2 specifications
1 parent 4ddd85a commit 908c0c8

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/util.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
exports.makeApiRequest = (config, endpoint, parameters) => {
22
const nf = require('node-fetch')
3-
const baseUrl = (config && config.baseUrl) || 'https://api.vultr.com/v1'
3+
const baseUrl = (config && config.baseUrl) || 'https://api.vultr.com/v2'
44
let fetchUrl = `${baseUrl}${endpoint.url}`
55
const options = {
66
method: endpoint.requestType,
77
headers: {
8-
'API-Key': (config && config.apiKey) || ''
8+
Authorization: config && config.apiKey ? `Bearer ${config.apiKey}` : ''
99
}
1010
}
1111

test/config.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
exports.apiKey = '123456789123456789123456789123456789'
2-
exports.baseUrl = 'https://api.vultr.com'
2+
exports.baseUrl = 'https://api.vultr.com/v2'
33
exports.headers = {
44
reqheaders: {
5-
'API-Key': /[A-Z0-9]{36}/i
5+
authorization: `Bearer 123456789123456789123456789123456789`
66
}
77
}
8-
exports.apiVersion = 'v1'
98
exports.rateLimit = 700

test/util.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ exports.createTestSuite = (specificationFile, mockData, mockParameters) => {
2525
beforeEach(() => {
2626
if (endpoint.requestType === 'GET') {
2727
nock(config.baseUrl, endpoint.apiKeyRequired ? config.headers : {})
28-
.get(`/${config.apiVersion}${endpoint.url}`)
28+
.get(`/${endpoint.url}`)
2929
.query((mockParameters && mockParameters[key]) || {})
3030
.reply(200, mockData[key] || undefined)
3131
} else if (endpoint.requestType === 'POST') {
3232
nock(config.baseUrl, config.headers)
3333
.post(
34-
`/${config.apiVersion}${endpoint.url}`,
34+
`/${endpoint.url}`,
3535
(mockParameters && mockParameters[key]) || {}
3636
)
3737
.reply(200, mockData[key] || undefined)

0 commit comments

Comments
 (0)