From ad6182771bb7006889a8000fbbe2419d5239baee Mon Sep 17 00:00:00 2001 From: calebcartwright Date: Sun, 15 Sep 2019 21:21:17 -0500 Subject: [PATCH] refactor(Jira): change query param name --- services/jira/jira-issue-redirect.service.js | 2 +- services/jira/jira-issue-redirect.tester.js | 2 +- services/jira/jira-issue.service.js | 8 ++++---- services/jira/jira-issue.spec.js | 2 +- services/jira/jira-issue.tester.js | 18 +++++++++--------- services/jira/jira-sprint-redirect.service.js | 2 +- services/jira/jira-sprint-redirect.tester.js | 2 +- services/jira/jira-sprint.service.js | 8 ++++---- services/jira/jira-sprint.spec.js | 2 +- services/jira/jira-sprint.tester.js | 12 ++++++------ 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/services/jira/jira-issue-redirect.service.js b/services/jira/jira-issue-redirect.service.js index 80f91ac2b36c2..1c98e875c303f 100644 --- a/services/jira/jira-issue-redirect.service.js +++ b/services/jira/jira-issue-redirect.service.js @@ -11,7 +11,7 @@ module.exports = [ }, transformPath: ({ issueKey }) => `/jira/issue/${issueKey}`, transformQueryParams: ({ protocol, hostAndPath }) => ({ - hostUrl: `${protocol}://${hostAndPath}`, + baseUrl: `${protocol}://${hostAndPath}`, }), dateAdded: new Date('2019-09-14'), }), diff --git a/services/jira/jira-issue-redirect.tester.js b/services/jira/jira-issue-redirect.tester.js index 2ceaa8ec427c7..5e40fc7b9b4b1 100644 --- a/services/jira/jira-issue-redirect.tester.js +++ b/services/jira/jira-issue-redirect.tester.js @@ -15,7 +15,7 @@ t.create('jira issue') .expectStatus(301) .expectHeader( 'Location', - `/jira/issue/kafka-2896.svg?hostUrl=${encodeURIComponent( + `/jira/issue/kafka-2896.svg?baseUrl=${encodeURIComponent( 'https://issues.apache.org/jira' )}` ) diff --git a/services/jira/jira-issue.service.js b/services/jira/jira-issue.service.js index e90b065c6589c..1ba8b98ad6468 100644 --- a/services/jira/jira-issue.service.js +++ b/services/jira/jira-issue.service.js @@ -6,7 +6,7 @@ const { authConfig } = require('./jira-common') const { BaseJsonService } = require('..') const queryParamSchema = Joi.object({ - hostUrl: optionalUrl.required(), + baseUrl: optionalUrl.required(), }).required() const schema = Joi.object({ @@ -45,7 +45,7 @@ module.exports = class JiraIssue extends BaseJsonService { issueKey: 'KAFKA-2896', }, queryParams: { - hostUrl: 'https://issues.apache.org/jira', + baseUrl: 'https://issues.apache.org/jira', }, staticPreview: this.render({ issueKey: 'KAFKA-2896', @@ -81,11 +81,11 @@ module.exports = class JiraIssue extends BaseJsonService { } } - async handle({ issueKey }, { hostUrl }) { + async handle({ issueKey }, { baseUrl }) { // Atlassian Documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-api-2-issue-issueIdOrKey-get const json = await this._requestJson({ schema, - url: `${hostUrl}/rest/api/2/issue/${encodeURIComponent(issueKey)}`, + url: `${baseUrl}/rest/api/2/issue/${encodeURIComponent(issueKey)}`, options: { auth: this.authHelper.basicAuth }, errorMessages: { 404: 'issue not found' }, }) diff --git a/services/jira/jira-issue.spec.js b/services/jira/jira-issue.spec.js index ae2bc7f46013c..26ecbc1d9b5f2 100644 --- a/services/jira/jira-issue.spec.js +++ b/services/jira/jira-issue.spec.js @@ -24,7 +24,7 @@ describe('JiraIssue', function() { { issueKey: 'secure-234', }, - { hostUrl: 'https://myprivatejira.test' } + { baseUrl: 'https://myprivatejira.test' } ) ).to.deep.equal({ label: 'secure-234', diff --git a/services/jira/jira-issue.tester.js b/services/jira/jira-issue.tester.js index db402b8fcc648..649510f939d34 100644 --- a/services/jira/jira-issue.tester.js +++ b/services/jira/jira-issue.tester.js @@ -3,15 +3,15 @@ const t = (module.exports = require('../tester').createServiceTester()) t.create('unknown issue') - .get('/notArealIssue-000.json?hostUrl=https://issues.apache.org/jira') + .get('/notArealIssue-000.json?baseUrl=https://issues.apache.org/jira') .expectBadge({ label: 'jira', message: 'issue not found' }) t.create('known issue') - .get('/kafka-2896.json?hostUrl=https://issues.apache.org/jira') + .get('/kafka-2896.json?baseUrl=https://issues.apache.org/jira') .expectBadge({ label: 'kafka-2896', message: 'Resolved' }) t.create('no status color') - .get('/foo-123.json?hostUrl=http://issues.apache.org/jira') + .get('/foo-123.json?baseUrl=http://issues.apache.org/jira') .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2/issue') .get(`/${encodeURIComponent('foo-123')}`) @@ -30,7 +30,7 @@ t.create('no status color') }) t.create('green status color') - .get('/bar-345.json?hostUrl=https://issues.apache.org:8000/jira') + .get('/bar-345.json?baseUrl=https://issues.apache.org:8000/jira') .intercept(nock => nock('https://issues.apache.org:8000/jira/rest/api/2/issue') .get(`/${encodeURIComponent('bar-345')}`) @@ -52,7 +52,7 @@ t.create('green status color') }) t.create('medium-gray status color') - .get('/abc-123.json?hostUrl=https://issues.apache.org:8080') + .get('/abc-123.json?baseUrl=https://issues.apache.org:8080') .intercept(nock => nock('https://issues.apache.org:8080/rest/api/2/issue') .get(`/${encodeURIComponent('abc-123')}`) @@ -74,7 +74,7 @@ t.create('medium-gray status color') }) t.create('yellow status color') - .get('/test-001.json?hostUrl=https://issues.apache.org') + .get('/test-001.json?baseUrl=https://issues.apache.org') .intercept(nock => nock('https://issues.apache.org/rest/api/2/issue') .get(`/${encodeURIComponent('test-001')}`) @@ -96,7 +96,7 @@ t.create('yellow status color') }) t.create('brown status color') - .get('/zzz-789.json?hostUrl=https://issues.apache.org') + .get('/zzz-789.json?baseUrl=https://issues.apache.org') .intercept(nock => nock('https://issues.apache.org/rest/api/2/issue') .get(`/${encodeURIComponent('zzz-789')}`) @@ -118,7 +118,7 @@ t.create('brown status color') }) t.create('warm-red status color') - .get('/fire-321.json?hostUrl=https://issues.apache.org') + .get('/fire-321.json?baseUrl=https://issues.apache.org') .intercept(nock => nock('https://issues.apache.org/rest/api/2/issue') .get(`/${encodeURIComponent('fire-321')}`) @@ -140,7 +140,7 @@ t.create('warm-red status color') }) t.create('blue-gray status color') - .get('/sky-775.json?hostUrl=https://issues.apache.org') + .get('/sky-775.json?baseUrl=https://issues.apache.org') .intercept(nock => nock('https://issues.apache.org/rest/api/2/issue') .get(`/${encodeURIComponent('sky-775')}`) diff --git a/services/jira/jira-sprint-redirect.service.js b/services/jira/jira-sprint-redirect.service.js index 8fc5832b86686..b3f460b044996 100644 --- a/services/jira/jira-sprint-redirect.service.js +++ b/services/jira/jira-sprint-redirect.service.js @@ -11,7 +11,7 @@ module.exports = [ }, transformPath: ({ sprintId }) => `/jira/sprint/${sprintId}`, transformQueryParams: ({ protocol, hostAndPath }) => ({ - hostUrl: `${protocol}://${hostAndPath}`, + baseUrl: `${protocol}://${hostAndPath}`, }), dateAdded: new Date('2019-09-14'), }), diff --git a/services/jira/jira-sprint-redirect.tester.js b/services/jira/jira-sprint-redirect.tester.js index 397fa9b5d5b17..64c0b223a3406 100644 --- a/services/jira/jira-sprint-redirect.tester.js +++ b/services/jira/jira-sprint-redirect.tester.js @@ -15,7 +15,7 @@ t.create('jira sprint') .expectStatus(301) .expectHeader( 'Location', - `/jira/sprint/94.svg?hostUrl=${encodeURIComponent( + `/jira/sprint/94.svg?baseUrl=${encodeURIComponent( 'https://jira.spring.io' )}` ) diff --git a/services/jira/jira-sprint.service.js b/services/jira/jira-sprint.service.js index 525eb19611baa..a75ca1e3b84c1 100644 --- a/services/jira/jira-sprint.service.js +++ b/services/jira/jira-sprint.service.js @@ -6,7 +6,7 @@ const { authConfig } = require('./jira-common') const { BaseJsonService } = require('..') const queryParamSchema = Joi.object({ - hostUrl: optionalUrl.required(), + baseUrl: optionalUrl.required(), }).required() const schema = Joi.object({ @@ -57,7 +57,7 @@ module.exports = class JiraSprint extends BaseJsonService { sprintId: '94', }, queryParams: { - hostUrl: 'https://jira.spring.io', + baseUrl: 'https://jira.spring.io', }, staticPreview: this.render({ numCompletedIssues: 27, @@ -90,12 +90,12 @@ module.exports = class JiraSprint extends BaseJsonService { } } - async handle({ sprintId }, { hostUrl }) { + async handle({ sprintId }, { baseUrl }) { // Atlassian Documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-group-Search // There are other sprint-specific APIs but those require authentication. The search API // allows us to get the needed data without being forced to authenticate. const json = await this._requestJson({ - url: `${hostUrl}/rest/api/2/search`, + url: `${baseUrl}/rest/api/2/search`, schema, options: { qs: { diff --git a/services/jira/jira-sprint.spec.js b/services/jira/jira-sprint.spec.js index b34f8516dbdc9..080a305f6c355 100644 --- a/services/jira/jira-sprint.spec.js +++ b/services/jira/jira-sprint.spec.js @@ -37,7 +37,7 @@ describe('JiraSprint', function() { { sprintId, }, - { hostUrl: 'https://myprivatejira.test/jira' } + { baseUrl: 'https://myprivatejira.test/jira' } ) ).to.deep.equal({ label: 'completion', diff --git a/services/jira/jira-sprint.tester.js b/services/jira/jira-sprint.tester.js index 4fb7348c7f5cd..fe817f6344d3f 100644 --- a/services/jira/jira-sprint.tester.js +++ b/services/jira/jira-sprint.tester.js @@ -5,18 +5,18 @@ const { isIntegerPercentage } = require('../test-validators') const { sprintId, sprintQueryString } = require('./jira-test-helpers') t.create('unknown sprint') - .get('/abc.json?hostUrl=https://jira.spring.io') + .get('/abc.json?baseUrl=https://jira.spring.io') .expectBadge({ label: 'jira', message: 'sprint not found' }) t.create('known sprint') - .get('/94.json?hostUrl=https://jira.spring.io') + .get('/94.json?baseUrl=https://jira.spring.io') .expectBadge({ label: 'completion', message: isIntegerPercentage, }) t.create('100% completion') - .get(`/${sprintId}.json?hostUrl=http://issues.apache.org/jira`) + .get(`/${sprintId}.json?baseUrl=http://issues.apache.org/jira`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -48,7 +48,7 @@ t.create('100% completion') }) t.create('0% completion') - .get(`/${sprintId}.json?hostUrl=http://issues.apache.org/jira`) + .get(`/${sprintId}.json?baseUrl=http://issues.apache.org/jira`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -73,7 +73,7 @@ t.create('0% completion') }) t.create('no issues in sprint') - .get(`/${sprintId}.json?hostUrl=http://issues.apache.org/jira`) + .get(`/${sprintId}.json?baseUrl=http://issues.apache.org/jira`) .intercept(nock => nock('http://issues.apache.org/jira/rest/api/2') .get('/search') @@ -90,7 +90,7 @@ t.create('no issues in sprint') }) t.create('issue with null resolution value') - .get(`/${sprintId}.json?hostUrl=https://jira.spring.io:8080`) + .get(`/${sprintId}.json?baseUrl=https://jira.spring.io:8080`) .intercept(nock => nock('https://jira.spring.io:8080/rest/api/2') .get('/search')