Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: screwdriver-cd/screwdriver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: screwdriver-cd/screwdriver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: another-scm-admins
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 14, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ff7331c View commit details
  2. add tests for the pipeline update

    VonnyJap committed Mar 14, 2025
    Copy the full SHA
    49eb2a8 View commit details
  3. removed comments and console log

    VonnyJap committed Mar 14, 2025
    Copy the full SHA
    4eb5238 View commit details
Showing with 28 additions and 1 deletion.
  1. +2 −1 plugins/pipelines/update.js
  2. +26 −0 test/plugins/pipelines.test.js
3 changes: 2 additions & 1 deletion plugins/pipelines/update.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,8 @@ const ANNOTATION_USE_DEPLOY_KEY = 'screwdriver.cd/useDeployKey';
*/
function getPermissionsForOldPipeline({ scmContexts, pipeline, user }) {
// this pipeline's scmContext has been removed, allow current admin to change it
if (!scmContexts.includes(pipeline.scmContext)) {
// also allow pipeline admins from other scmContexts to change it
if (!scmContexts.includes(pipeline.scmContext) || user.scmContext !== pipeline.scmContext) {
const permission = { admin: false };

if (pipeline.admins[user.username]) {
26 changes: 26 additions & 0 deletions test/plugins/pipelines.test.js
Original file line number Diff line number Diff line change
@@ -2942,6 +2942,32 @@ describe('pipeline plugin test', () => {
});
});

it('returns 200 when the user is admin from different scmContext', () => {
userMock.scmContext = 'gitlab:mygitlab';
pipelineMock.admins = { [username]: true };

return server.inject(options).then(reply => {
// Only call once to get permissions on the new repo
assert.calledOnce(userMock.getPermissions);
assert.calledWith(userMock.getPermissions, scmUri);
assert.calledOnce(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 200);
});
});

it('returns 403 when the user is not admin from different scmContext', () => {
userMock.scmContext = 'gitlab:mygitlab';
pipelineMock.admins = { ohno: true };

return server.inject(options).then(reply => {
// Only call once to get permissions on the new repo
assert.calledOnce(userMock.getPermissions);
assert.calledWith(userMock.getPermissions, scmUri);
assert.notCalled(updatedPipelineMock.addWebhooks);
assert.equal(reply.statusCode, 403);
});
});

it('returns 401 when the pipeline token does not have permission', () => {
options.auth.credentials = {
username,