Skip to content

Commit 1a4767c

Browse files
committed
auth changes
1 parent 8edad96 commit 1a4767c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/lib/httpClient.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import constants from './constants.js';
66
import type { Logger } from 'winston'
77
import pkgJSON from './../../package.json'
88
import https from 'https';
9+
import logger from './logger.js';
910

1011
export default class httpClient {
1112
axiosInstance: AxiosInstance;
@@ -142,7 +143,12 @@ export default class httpClient {
142143
const response = await this.request({
143144
url: '/token/verify',
144145
method: 'GET',
146+
headers:{
147+
userName : env.LT_USERNAME,
148+
accessKey: env.LT_ACCESS_KEY
149+
}
145150
}, log);
151+
logger.debug(`Response from auth is ${JSON.stringify(response)}`);
146152
if (response && response.projectToken) {
147153
this.projectToken = response.projectToken;
148154
env.PROJECT_TOKEN = response.projectToken;
@@ -157,8 +163,8 @@ export default class httpClient {
157163

158164
async authExec(ctx: Context, log: Logger, env: Env): Promise<{ authResult: number, orgId: number, userId: number }> {
159165
let authResult = 1;
160-
let userName = '';
161-
let passWord = '';
166+
let userName = ctx.env.LT_USERNAME;
167+
let passWord = ctx.env.LT_ACCESS_KEY;
162168
if (ctx.config.tunnel) {
163169
if (ctx.config.tunnel?.user && ctx.config.tunnel?.key) {
164170
userName = ctx.config.tunnel.user
@@ -179,6 +185,7 @@ export default class httpClient {
179185
accessKey: passWord
180186
}
181187
}, log);
188+
ctx.log.debug(`Response from authExec is ${JSON.stringify(response)}`);
182189
if (response && response.projectToken) {
183190
let orgId = 0;
184191
let userId = 0;
@@ -202,7 +209,7 @@ export default class httpClient {
202209
}
203210
}
204211

205-
createBuild(git: Git, config: any, log: Logger, buildName: string, isStartExec: boolean, smartGit: boolean, markBaseline: boolean, baselineBuild: string, scheduled?: string) {
212+
createBuild(git: Git, config: any, log: Logger, buildName: string, isStartExec: boolean, smartGit: boolean, markBaseline: boolean, baselineBuild: string, scheduled?: string,userName?: string,accessKey?: string) {
206213
return this.request({
207214
url: '/build',
208215
method: 'POST',
@@ -215,7 +222,9 @@ export default class httpClient {
215222
smartGit,
216223
markBaseline,
217224
baselineBuild,
218-
scheduled
225+
scheduled,
226+
userName,
227+
accessKey
219228
}
220229
}, log)
221230
}

src/tasks/createBuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1010
updateLogContext({task: 'createBuild'});
1111

1212
try {
13-
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name, ctx.isStartExec, ctx.env.SMART_GIT, ctx.options.markBaseline, ctx.options.baselineBuild, ctx.options.scheduled);
13+
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name, ctx.isStartExec, ctx.env.SMART_GIT, ctx.options.markBaseline, ctx.options.baselineBuild, ctx.options.scheduled,ctx.env.LT_USERNAME,ctx.env.LT_ACCESS_KEY);
1414
if (resp && resp.data && resp.data.buildId) {
1515
ctx.build = {
1616
id: resp.data.buildId,

src/tasks/createBuildExec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1212

1313
try {
1414
if (ctx.authenticatedInitially && !ctx.config.skipBuildCreation) {
15-
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name, ctx.isStartExec, ctx.env.SMART_GIT, ctx.options.markBaseline, ctx.options.baselineBuild, ctx.options.scheduled);
15+
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name, ctx.isStartExec, ctx.env.SMART_GIT, ctx.options.markBaseline, ctx.options.baselineBuild, ctx.options.scheduled,ctx.env.LT_USERNAME,ctx.env.LT_ACCESS_KEY);
1616
if (resp && resp.data && resp.data.buildId) {
1717
ctx.build = {
1818
id: resp.data.buildId,

0 commit comments

Comments
 (0)