From 8b05faeb7f01c552724c2280ae2ac834e5b61a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Tue, 7 Sep 2021 19:55:42 +0200 Subject: [PATCH 1/8] service: add obs service --- config/custom-environment-variables.yml | 4 ++ config/default.yml | 2 + config/local.template.yml | 2 + core/server/server.js | 5 ++ doc/server-secrets.md | 16 +++++ services/obs/obs-build-status.js | 69 ++++++++++++++++++++++ services/obs/obs.service.js | 77 +++++++++++++++++++++++++ services/obs/obs.tester.js | 25 ++++++++ 8 files changed, 200 insertions(+) create mode 100644 services/obs/obs-build-status.js create mode 100644 services/obs/obs.service.js create mode 100644 services/obs/obs.tester.js diff --git a/config/custom-environment-variables.yml b/config/custom-environment-variables.yml index 3795a2af1de81..45ae2fc7f7863 100644 --- a/config/custom-environment-variables.yml +++ b/config/custom-environment-variables.yml @@ -50,6 +50,8 @@ public: authorizedOrigins: 'NEXUS_ORIGINS' npm: authorizedOrigins: 'NPM_ORIGINS' + obs: + instance: 'OBS_INSTANCE' sonar: authorizedOrigins: 'SONAR_ORIGINS' teamcity: @@ -87,6 +89,8 @@ private: nexus_user: 'NEXUS_USER' nexus_pass: 'NEXUS_PASS' npm_token: 'NPM_TOKEN' + obs_userName: 'OBS_USER_NAME' + obs_userPass: 'OBS_USER_PASS' redis_url: 'REDIS_URL' sentry_dsn: 'SENTRY_DSN' shields_secret: 'SHIELDS_SECRET' diff --git a/config/default.yml b/config/default.yml index 973de381324a3..07b0d1a7896b8 100644 --- a/config/default.yml +++ b/config/default.yml @@ -22,6 +22,8 @@ public: debug: enabled: false intervalSeconds: 200 + obs: + instance: 'https://api.opensuse.org' weblate: authorizedOrigins: 'https://hosted.weblate.org' trace: false diff --git a/config/local.template.yml b/config/local.template.yml index af36abf238756..e5fea251b4f12 100644 --- a/config/local.template.yml +++ b/config/local.template.yml @@ -6,6 +6,8 @@ private: # preferable for self hosting. gh_token: '...' gitlab_token: '...' + obs_userName: '...' + obs_userPass: '...' twitch_client_id: '...' twitch_client_secret: '...' weblate_api_key: '...' diff --git a/core/server/server.js b/core/server/server.js index 9a4cacf7b938d..e494250038d3a 100644 --- a/core/server/server.js +++ b/core/server/server.js @@ -134,6 +134,9 @@ const publicConfigSchema = Joi.object({ }).default({ authorizedOrigins: [] }), nexus: defaultService, npm: defaultService, + obs: Joi.object({ + instance: requiredUrl, + }), sonar: defaultService, teamcity: defaultService, weblate: defaultService, @@ -172,6 +175,8 @@ const privateConfigSchema = Joi.object({ nexus_user: Joi.string(), nexus_pass: Joi.string(), npm_token: Joi.string(), + obs_userName: Joi.string(), + obs_userPass: Joi.string(), redis_url: Joi.string().uri({ scheme: ['redis', 'rediss'] }), sentry_dsn: Joi.string(), shields_secret: Joi.string(), diff --git a/doc/server-secrets.md b/doc/server-secrets.md index 9f089ef0e4714..477b6268a85d8 100644 --- a/doc/server-secrets.md +++ b/doc/server-secrets.md @@ -193,6 +193,22 @@ installation access to private npm packages [npm token]: https://docs.npmjs.com/getting-started/working_with_tokens +## Open Build Service + +- `OBS_INSTANCE` (yml: `public.services.obs.instance`) +- `OBS_USER_NAME` (yml: `private.obs_userName`) +- `OBS_USER_PASS` (yml: `private.obs_userPass`) + +Only authenticated users are allowed to access the Open Build Service API. +Authentication is done by sending a Basic HTTP Authorisation header. A user +account for the [reference instance](https://build.opensuse.org) is a SUSE +IdP account, which can be created [here](https://idp-portal.suse.com/univention/self-service/#page=createaccount). + +While OBS supports [API tokens](https://openbuildservice.org/help/manuals/obs-user-guide/cha.obs.authorization.token.html#id-1.5.10.16.4), +they can only be scoped to execute specific actions on a POST request. This +means however, that an actual account is required to read the build status +of a package. + ### SymfonyInsight (formerly Sensiolabs) - `SL_INSIGHT_USER_UUID` (yml: `private.sl_insight_userUuid`) diff --git a/services/obs/obs-build-status.js b/services/obs/obs-build-status.js new file mode 100644 index 0000000000000..d3a6791c439b8 --- /dev/null +++ b/services/obs/obs-build-status.js @@ -0,0 +1,69 @@ +import Joi from 'joi' + +// colors from OBS webinterface +/* const statusmap = { + //Green + succeeded: "#008000", + // Blue + building: "#069", + // Cyan + scheduled: "#007a7c", + // Yellow + signing: "#f0ad4e", + finished: "#f0ad4e", + // Red + unresolvable: "#dc3545", + broken: "#dc3545", + failed: "#dc3545", + // Gray + disabled: "#6c757d", + blocked: "#6c757d", + // Orange + "scheduled-warning": "#a50", + unknown: "#a50" +} */ + +// shields colors +const statusmap = { + // Green + succeeded: 'success', + // Blue + building: 'blue', + // Cyan + scheduled: '#007a7c', + // Yellow + signing: 'yellow', + finished: 'yellow', + // Red + unresolvable: 'critical', + broken: 'critical', + failed: 'critical', + // Gray + disabled: 'inactive', + blocked: 'inactive', + // Orange + 'scheduled-warning': 'important', + unknown: 'lightgray', +} + +const isBuildStatus = Joi.equal(...Object.keys(statusmap)) +function getIsMessageStatus() { + const status = [] + Object.keys(statusmap).forEach(key => + status.push(key.charAt(0).toUpperCase() + key.slice(1)) + ) + + return Joi.equal(...status) +} + +function renderBuildStatusBadge({ repository, status }) { + const color = statusmap[status] + + return { + label: repository.replaceAll('_', ' '), + message: status.charAt(0).toUpperCase() + status.slice(1), + color, + } +} + +export { isBuildStatus, getIsMessageStatus, renderBuildStatusBadge } diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js new file mode 100644 index 0000000000000..24e71f4fefb6c --- /dev/null +++ b/services/obs/obs.service.js @@ -0,0 +1,77 @@ +import Joi from 'joi' +import { BaseXmlService } from '../index.js' +import { isBuildStatus, renderBuildStatusBadge } from './obs-build-status.js' + +const schema = Joi.object({ + status: Joi.object({ + '@_code': isBuildStatus, + }).required(), +}).required() + +export default class ObsService extends BaseXmlService { + static category = 'build' + static route = { + base: 'obs', + pattern: ':project/:packageName/:repository/:arch', + } + static auth = { + userKey: 'obs_userName', + passKey: 'obs_userPass', + authorizedOrigins: [], + isRequired: true, + } + + static examples = [ + { + title: 'openSUSE OBS package build status', + namedParams: { + project: 'openSUSE:Tools', + packageName: 'osc', + repository: 'Debian_11', + arch: 'x86_64', + }, + staticPreview: this.render({ + repository: 'Debian_11', + status: 'succeeded', + }), + keywords: ['open build service'], + }, + ] + + static defaultBadgeData = { label: 'OBS' } + + static render({ repository, status }) { + return renderBuildStatusBadge({ repository, status }) + } + + constructor(context, config) { + super(context, config) + this.instance = config.public.services.obs.instance + const { protocol, host } = new URL(this.instance) + this.authHelper._authorizedOrigins = [`${protocol}//${host}`] + } + + async fetch({ project, packageName, repository, arch }) { + return this._requestXml( + this.authHelper.withBasicAuth({ + schema, + url: `${this.instance}/build/${project}/${repository}/${arch}/${packageName}/_status`, + errorMessages: { + 401: 'Not authorized', + 404: 'Package not found', // extend this to project/package/repository/arch? + }, + parserOptions: { + ignoreAttributes: false, + }, + }) + ) + } + + async handle({ project, packageName, repository, arch }) { + const resp = await this.fetch({ project, packageName, repository, arch }) + return this.constructor.render({ + repository, + status: resp.status['@_code'], + }) + } +} diff --git a/services/obs/obs.tester.js b/services/obs/obs.tester.js new file mode 100644 index 0000000000000..2ab817ea4c65c --- /dev/null +++ b/services/obs/obs.tester.js @@ -0,0 +1,25 @@ +import { ServiceTester } from '../tester.js' +import { noToken } from '../test-helpers.js' +import ObsService from './obs.service.js' +import { getIsMessageStatus } from './obs-build-status.js' + +export const t = new ServiceTester({ + id: 'obs', + title: 'openSUSE Open Build Service', +}) + +t.create('status (valid)') + .skipWhen(noToken(ObsService)) + .get('/openSUSE:Factory/aaa_base/standard/x86_64.json') + .expectBadge({ + label: 'standard', + message: getIsMessageStatus(), + }) + +t.create('status (invalid)') + .skipWhen(noToken(ObsService)) + .get('/home:sp1rit/this_package_will_never_exist/repo/arch.json') + .expectBadge({ + label: 'OBS', + message: 'Package not found', + }) From d853bf7b2fa5dd13df524e091f7e501a13f30b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Wed, 8 Sep 2021 11:09:07 +0200 Subject: [PATCH 2/8] service: obs: replaced replaceAll with replace and global regex --- services/obs/obs-build-status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/obs/obs-build-status.js b/services/obs/obs-build-status.js index d3a6791c439b8..808733d6431c4 100644 --- a/services/obs/obs-build-status.js +++ b/services/obs/obs-build-status.js @@ -60,7 +60,7 @@ function renderBuildStatusBadge({ repository, status }) { const color = statusmap[status] return { - label: repository.replaceAll('_', ' '), + label: repository.replace(/_/g, ' '), message: status.charAt(0).toUpperCase() + status.slice(1), color, } From 09d664006215c0c0183848158bc3dd7f64149218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Thu, 9 Sep 2021 12:23:00 +0200 Subject: [PATCH 3/8] service: obs: added space between class members --- services/obs/obs.service.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index 24e71f4fefb6c..8aa119968b17a 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -14,6 +14,7 @@ export default class ObsService extends BaseXmlService { base: 'obs', pattern: ':project/:packageName/:repository/:arch', } + static auth = { userKey: 'obs_userName', passKey: 'obs_userPass', From 2ce321c388c68f1f79b102fd9030f6059b5cf9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Tue, 14 Sep 2021 17:52:56 +0200 Subject: [PATCH 4/8] service: obs: support for multiple instances --- config/custom-environment-variables.yml | 2 +- config/default.yml | 2 +- core/server/server.js | 4 +--- services/obs/obs.service.js | 30 +++++++++++++++++++------ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/config/custom-environment-variables.yml b/config/custom-environment-variables.yml index 45ae2fc7f7863..0ac02df9b67a3 100644 --- a/config/custom-environment-variables.yml +++ b/config/custom-environment-variables.yml @@ -51,7 +51,7 @@ public: npm: authorizedOrigins: 'NPM_ORIGINS' obs: - instance: 'OBS_INSTANCE' + authorizedOrigins: 'OBS_ORIGINS' sonar: authorizedOrigins: 'SONAR_ORIGINS' teamcity: diff --git a/config/default.yml b/config/default.yml index 07b0d1a7896b8..41dc14e5f319c 100644 --- a/config/default.yml +++ b/config/default.yml @@ -23,7 +23,7 @@ public: enabled: false intervalSeconds: 200 obs: - instance: 'https://api.opensuse.org' + authorizedOrigins: 'https://api.opensuse.org' weblate: authorizedOrigins: 'https://hosted.weblate.org' trace: false diff --git a/core/server/server.js b/core/server/server.js index e494250038d3a..628a44e3f9f15 100644 --- a/core/server/server.js +++ b/core/server/server.js @@ -134,9 +134,7 @@ const publicConfigSchema = Joi.object({ }).default({ authorizedOrigins: [] }), nexus: defaultService, npm: defaultService, - obs: Joi.object({ - instance: requiredUrl, - }), + obs: defaultService, sonar: defaultService, teamcity: defaultService, weblate: defaultService, diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index 8aa119968b17a..8d2f66990107a 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -1,5 +1,6 @@ import Joi from 'joi' import { BaseXmlService } from '../index.js' +import { optionalUrl } from '../validators.js' import { isBuildStatus, renderBuildStatusBadge } from './obs-build-status.js' const schema = Joi.object({ @@ -13,6 +14,9 @@ export default class ObsService extends BaseXmlService { static route = { base: 'obs', pattern: ':project/:packageName/:repository/:arch', + queryParamSchema: Joi.object({ + instance: optionalUrl, + }).required(), } static auth = { @@ -47,16 +51,19 @@ export default class ObsService extends BaseXmlService { constructor(context, config) { super(context, config) - this.instance = config.public.services.obs.instance - const { protocol, host } = new URL(this.instance) - this.authHelper._authorizedOrigins = [`${protocol}//${host}`] + const origins = [] + config.public.services.obs.authorizedOrigins.forEach(origin => { + const { protocol, host } = new URL(origin) + origins.push(`${protocol}//${host}`) + }) + this.authHelper._authorizedOrigins = origins } - async fetch({ project, packageName, repository, arch }) { + async fetch({ instance, project, packageName, repository, arch }) { return this._requestXml( this.authHelper.withBasicAuth({ schema, - url: `${this.instance}/build/${project}/${repository}/${arch}/${packageName}/_status`, + url: `${instance}/build/${project}/${repository}/${arch}/${packageName}/_status`, errorMessages: { 401: 'Not authorized', 404: 'Package not found', // extend this to project/package/repository/arch? @@ -68,8 +75,17 @@ export default class ObsService extends BaseXmlService { ) } - async handle({ project, packageName, repository, arch }) { - const resp = await this.fetch({ project, packageName, repository, arch }) + async handle( + { project, packageName, repository, arch }, + { instance = 'https://api.opensuse.org' } + ) { + const resp = await this.fetch({ + instance, + project, + packageName, + repository, + arch, + }) return this.constructor.render({ repository, status: resp.status['@_code'], From 8aaf198ca2212687c91d615ce3ab6fd883e94c20 Mon Sep 17 00:00:00 2001 From: "Florian \"sp1rit" <31540351+sp1ritCS@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:47:40 +0000 Subject: [PATCH 5/8] service: obs: removed user prefix from auth vars obs_userName is now called obs_user and obs_userPass is called obs_pass Co-authored-by: Caleb Cartwright --- config/custom-environment-variables.yml | 4 ++-- config/local.template.yml | 4 ++-- core/server/server.js | 4 ++-- doc/server-secrets.md | 5 ++--- services/obs/obs.service.js | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/config/custom-environment-variables.yml b/config/custom-environment-variables.yml index 0ac02df9b67a3..3afe51a5450b5 100644 --- a/config/custom-environment-variables.yml +++ b/config/custom-environment-variables.yml @@ -89,8 +89,8 @@ private: nexus_user: 'NEXUS_USER' nexus_pass: 'NEXUS_PASS' npm_token: 'NPM_TOKEN' - obs_userName: 'OBS_USER_NAME' - obs_userPass: 'OBS_USER_PASS' + obs_user: 'OBS_USER' + obs_pass: 'OBS_PASS' redis_url: 'REDIS_URL' sentry_dsn: 'SENTRY_DSN' shields_secret: 'SHIELDS_SECRET' diff --git a/config/local.template.yml b/config/local.template.yml index e5fea251b4f12..ae1c51c619ebf 100644 --- a/config/local.template.yml +++ b/config/local.template.yml @@ -6,8 +6,8 @@ private: # preferable for self hosting. gh_token: '...' gitlab_token: '...' - obs_userName: '...' - obs_userPass: '...' + obs_user: '...' + obs_pass: '...' twitch_client_id: '...' twitch_client_secret: '...' weblate_api_key: '...' diff --git a/core/server/server.js b/core/server/server.js index 628a44e3f9f15..8b5b166b35719 100644 --- a/core/server/server.js +++ b/core/server/server.js @@ -173,8 +173,8 @@ const privateConfigSchema = Joi.object({ nexus_user: Joi.string(), nexus_pass: Joi.string(), npm_token: Joi.string(), - obs_userName: Joi.string(), - obs_userPass: Joi.string(), + obs_user: Joi.string(), + obs_pass: Joi.string(), redis_url: Joi.string().uri({ scheme: ['redis', 'rediss'] }), sentry_dsn: Joi.string(), shields_secret: Joi.string(), diff --git a/doc/server-secrets.md b/doc/server-secrets.md index 477b6268a85d8..02b7ad1534c35 100644 --- a/doc/server-secrets.md +++ b/doc/server-secrets.md @@ -195,9 +195,8 @@ installation access to private npm packages ## Open Build Service -- `OBS_INSTANCE` (yml: `public.services.obs.instance`) -- `OBS_USER_NAME` (yml: `private.obs_userName`) -- `OBS_USER_PASS` (yml: `private.obs_userPass`) +- `OBS_USER` (yml: `private.obs_user`) +- `OBS_PASS` (yml: `private.obs_user`) Only authenticated users are allowed to access the Open Build Service API. Authentication is done by sending a Basic HTTP Authorisation header. A user diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index 8d2f66990107a..bc38af68520fd 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -20,8 +20,8 @@ export default class ObsService extends BaseXmlService { } static auth = { - userKey: 'obs_userName', - passKey: 'obs_userPass', + userKey: 'obs_user', + passKey: 'obs_pass', authorizedOrigins: [], isRequired: true, } From 10e33d197977474020ba38c572e9f848023dd09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Sat, 25 Sep 2021 11:04:47 +0200 Subject: [PATCH 6/8] service: obs: removed constructor hack in favour of serviceKey --- services/obs/obs.service.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index bc38af68520fd..f118af7db04fd 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -22,7 +22,7 @@ export default class ObsService extends BaseXmlService { static auth = { userKey: 'obs_user', passKey: 'obs_pass', - authorizedOrigins: [], + serviceKey: 'obs', isRequired: true, } @@ -49,16 +49,6 @@ export default class ObsService extends BaseXmlService { return renderBuildStatusBadge({ repository, status }) } - constructor(context, config) { - super(context, config) - const origins = [] - config.public.services.obs.authorizedOrigins.forEach(origin => { - const { protocol, host } = new URL(origin) - origins.push(`${protocol}//${host}`) - }) - this.authHelper._authorizedOrigins = origins - } - async fetch({ instance, project, packageName, repository, arch }) { return this._requestXml( this.authHelper.withBasicAuth({ From c5b68869b66f669f9f0e7ac43938f2ba9ee7e9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Sat, 25 Sep 2021 11:55:23 +0200 Subject: [PATCH 7/8] service: obs: apply suggestions from @calebcartwright --- services/build-status.js | 1 + services/build-status.spec.js | 1 + services/obs/obs-build-status.js | 83 +++++++++----------------------- services/obs/obs.service.js | 5 +- services/obs/obs.tester.js | 10 ++-- 5 files changed, 34 insertions(+), 66 deletions(-) diff --git a/services/build-status.js b/services/build-status.js index 0a143bcdde8e0..a658ff411e6ad 100644 --- a/services/build-status.js +++ b/services/build-status.js @@ -12,6 +12,7 @@ const greenStatuses = [ const orangeStatuses = ['partially succeeded', 'unstable', 'timeout'] const redStatuses = [ + 'broken', 'error', 'errored', 'failed', diff --git a/services/build-status.spec.js b/services/build-status.spec.js index 4708f43522a7c..b135504bcbe78 100644 --- a/services/build-status.spec.js +++ b/services/build-status.spec.js @@ -53,6 +53,7 @@ test(renderBuildStatusBadge, () => { test(renderBuildStatusBadge, () => { forCases([ + given({ status: 'broken' }), given({ status: 'error' }), given({ status: 'errored' }), given({ status: 'failed' }), diff --git a/services/obs/obs-build-status.js b/services/obs/obs-build-status.js index 808733d6431c4..0be8d3fd2553f 100644 --- a/services/obs/obs-build-status.js +++ b/services/obs/obs-build-status.js @@ -1,69 +1,34 @@ import Joi from 'joi' +import { + isBuildStatus as gIsBuildStatus, + renderBuildStatusBadge as gRenderBuildStatusBadge, +} from '../build-status.js' -// colors from OBS webinterface -/* const statusmap = { - //Green - succeeded: "#008000", - // Blue - building: "#069", - // Cyan - scheduled: "#007a7c", - // Yellow - signing: "#f0ad4e", - finished: "#f0ad4e", - // Red - unresolvable: "#dc3545", - broken: "#dc3545", - failed: "#dc3545", - // Gray - disabled: "#6c757d", - blocked: "#6c757d", - // Orange - "scheduled-warning": "#a50", - unknown: "#a50" -} */ - -// shields colors -const statusmap = { - // Green - succeeded: 'success', - // Blue - building: 'blue', - // Cyan - scheduled: '#007a7c', - // Yellow - signing: 'yellow', - finished: 'yellow', - // Red - unresolvable: 'critical', - broken: 'critical', - failed: 'critical', - // Gray - disabled: 'inactive', +const localStatuses = { blocked: 'inactive', - // Orange - 'scheduled-warning': 'important', - unknown: 'lightgray', + disabled: 'inactive', + finished: 'orange', + 'scheduled-warning': 'orange', + signing: 'orange', + unknown: 'inactive', + unresolvable: 'red', } -const isBuildStatus = Joi.equal(...Object.keys(statusmap)) -function getIsMessageStatus() { - const status = [] - Object.keys(statusmap).forEach(key => - status.push(key.charAt(0).toUpperCase() + key.slice(1)) - ) - - return Joi.equal(...status) -} +const isBuildStatus = Joi.alternatives().try( + gIsBuildStatus, + Joi.equal(...Object.keys(localStatuses)) +) function renderBuildStatusBadge({ repository, status }) { - const color = statusmap[status] - - return { - label: repository.replace(/_/g, ' '), - message: status.charAt(0).toUpperCase() + status.slice(1), - color, + const color = localStatuses[status] + if (color) { + return { + message: status.toLowerCase(), + color, + } + } else { + return gRenderBuildStatusBadge({ status: status.toLowerCase() }) } } -export { isBuildStatus, getIsMessageStatus, renderBuildStatusBadge } +export { isBuildStatus, renderBuildStatusBadge } diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index f118af7db04fd..7b70983e30f24 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -28,13 +28,14 @@ export default class ObsService extends BaseXmlService { static examples = [ { - title: 'openSUSE OBS package build status', + title: 'OBS package build status', namedParams: { project: 'openSUSE:Tools', packageName: 'osc', repository: 'Debian_11', arch: 'x86_64', }, + queryParams: { instance: 'https://api.opensuse.org' }, staticPreview: this.render({ repository: 'Debian_11', status: 'succeeded', @@ -43,7 +44,7 @@ export default class ObsService extends BaseXmlService { }, ] - static defaultBadgeData = { label: 'OBS' } + static defaultBadgeData = { label: 'build' } static render({ repository, status }) { return renderBuildStatusBadge({ repository, status }) diff --git a/services/obs/obs.tester.js b/services/obs/obs.tester.js index 2ab817ea4c65c..f05714f781212 100644 --- a/services/obs/obs.tester.js +++ b/services/obs/obs.tester.js @@ -1,7 +1,7 @@ import { ServiceTester } from '../tester.js' import { noToken } from '../test-helpers.js' import ObsService from './obs.service.js' -import { getIsMessageStatus } from './obs-build-status.js' +import { isBuildStatus } from './obs-build-status.js' export const t = new ServiceTester({ id: 'obs', @@ -10,16 +10,16 @@ export const t = new ServiceTester({ t.create('status (valid)') .skipWhen(noToken(ObsService)) - .get('/openSUSE:Factory/aaa_base/standard/x86_64.json') + .get('/openSUSE:Factory/aaa_base/standard/x86_64.json?label=standard') .expectBadge({ label: 'standard', - message: getIsMessageStatus(), + message: isBuildStatus, }) t.create('status (invalid)') .skipWhen(noToken(ObsService)) .get('/home:sp1rit/this_package_will_never_exist/repo/arch.json') .expectBadge({ - label: 'OBS', - message: 'Package not found', + label: 'build', + message: 'not found', }) From 5be190763cae03ce3b32f3cc0e37229f005bf1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Sat, 25 Sep 2021 18:08:46 +0200 Subject: [PATCH 8/8] service: obs: remove unneccesary http status mappings --- services/obs/obs.service.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/services/obs/obs.service.js b/services/obs/obs.service.js index 7b70983e30f24..d6c6304eeeb17 100644 --- a/services/obs/obs.service.js +++ b/services/obs/obs.service.js @@ -55,10 +55,6 @@ export default class ObsService extends BaseXmlService { this.authHelper.withBasicAuth({ schema, url: `${instance}/build/${project}/${repository}/${arch}/${packageName}/_status`, - errorMessages: { - 401: 'Not authorized', - 404: 'Package not found', // extend this to project/package/repository/arch? - }, parserOptions: { ignoreAttributes: false, },