From 8b8833c16d84b063f5b3cc5975b7e8a200c9b729 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Thu, 13 Oct 2022 20:34:45 -0500 Subject: [PATCH] fix: fix path on requestOptions --- lib/authorization-server-request.js | 2 +- lib/basic-auth-request.js | 2 +- test/authorization-server-request-test.js | 4 ++-- test/basic-auth-request-test.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/authorization-server-request.js b/lib/authorization-server-request.js index 5f87f21..e5cd2ad 100644 --- a/lib/authorization-server-request.js +++ b/lib/authorization-server-request.js @@ -22,7 +22,7 @@ const getAuthUrlFromOCP = async (url, insecureSkipTlsVerify = true) => { } }); const requestOptions = { - path: '.well-known/oauth-authorization-server', + path: '/.well-known/oauth-authorization-server', method: 'GET' }; client.request(requestOptions).then(async (responseData) => { diff --git a/lib/basic-auth-request.js b/lib/basic-auth-request.js index 639f5df..539fc09 100644 --- a/lib/basic-auth-request.js +++ b/lib/basic-auth-request.js @@ -19,7 +19,7 @@ async function getUserFromAuthToken (settings) { } }); const requestOptions = { - path: 'apis/user.openshift.io/v1/users/~', + path: '/apis/user.openshift.io/v1/users/~', method: 'GET', headers: { Authorization: `Bearer ${settings.token}` } }; diff --git a/test/authorization-server-request-test.js b/test/authorization-server-request-test.js index e10d76a..b5a0765 100644 --- a/test/authorization-server-request-test.js +++ b/test/authorization-server-request-test.js @@ -2,7 +2,7 @@ const test = require('tape'); const proxyquire = require('proxyquire'); -const BASE_URL = 'http://some.cluster.com:6443/'; +const BASE_URL = 'http://some.cluster.com:6443'; function create (MockClient) { return proxyquire('../lib/authorization-server-request', { @@ -58,7 +58,7 @@ test('authorization server request URL join safety', (t) => { } request (options) { - t.equal(this.url + options.path, `${BASE_URL}.well-known/oauth-authorization-server`); + t.equal(this.url + options.path, `${BASE_URL}/.well-known/oauth-authorization-server`); return new Promise((resolve, reject) => { resolve({ statusCode: 200, diff --git a/test/basic-auth-request-test.js b/test/basic-auth-request-test.js index 8797966..ce9c61c 100644 --- a/test/basic-auth-request-test.js +++ b/test/basic-auth-request-test.js @@ -2,7 +2,7 @@ const test = require('tape'); const proxyquire = require('proxyquire'); -const BASE_URL = 'http://some.cluster.com:6443/'; +const BASE_URL = 'http://some.cluster.com:6443'; test('basic auth request', (t) => { class MockClient { @@ -278,7 +278,7 @@ test('get user from token URL join safety', (t) => { } request (options) { - t.equal(this.url + options.path, `${BASE_URL}apis/user.openshift.io/v1/users/~`); + t.equal(this.url + options.path, `${BASE_URL}/apis/user.openshift.io/v1/users/~`); return new Promise((resolve, reject) => { resolve({ statusCode: 200,