Skip to content

Commit 91e3d9b

Browse files
committed
UI: Add support for trusted-publishing token scope
1 parent f98d0d6 commit 91e3d9b

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

app/controllers/settings/tokens/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class NewTokenController extends Controller {
2323
@tracked scopesInvalid;
2424
@tracked crateScopes;
2525

26-
ENDPOINT_SCOPES = ['change-owners', 'publish-new', 'publish-update', 'yank'];
26+
ENDPOINT_SCOPES = ['change-owners', 'publish-new', 'publish-update', 'trusted-publishing', 'yank'];
2727

2828
scopeDescription = scopeDescription;
2929

app/utils/token-scopes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const DESCRIPTIONS = {
44
'change-owners': 'Invite new crate owners or remove existing ones',
55
'publish-new': 'Publish new crates',
66
'publish-update': 'Publish new versions of existing crates',
7+
'trusted-publishing': 'Manage trusted publishing configurations',
78
yank: 'Yank and unyank crate versions',
89
};
910

tests/routes/settings/tokens/new-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,30 @@ module('/settings/tokens/new', function (hooks) {
346346
assert.strictEqual(currentURL(), '/settings/tokens/new?from=1');
347347
assert.dom('[data-test-title]').hasText('Token not found');
348348
});
349+
350+
test('trusted-publishing scope', async function (assert) {
351+
prepare(this);
352+
353+
await visit('/settings/tokens/new');
354+
assert.strictEqual(currentURL(), '/settings/tokens/new');
355+
356+
await fillIn('[data-test-name]', 'trusted-publishing-token');
357+
await select('[data-test-expiry]', 'none');
358+
await click('[data-test-scope="trusted-publishing"]');
359+
await click('[data-test-generate]');
360+
361+
let token = this.db.apiToken.findFirst({ where: { name: { equals: 'trusted-publishing-token' } } });
362+
assert.ok(Boolean(token), 'API token has been created in the backend database');
363+
assert.strictEqual(token.name, 'trusted-publishing-token');
364+
assert.strictEqual(token.expiredAt, null);
365+
assert.strictEqual(token.crateScopes, null);
366+
assert.deepEqual(token.endpointScopes, ['trusted-publishing']);
367+
368+
assert.strictEqual(currentURL(), '/settings/tokens');
369+
assert.dom('[data-test-api-token="1"] [data-test-name]').hasText('trusted-publishing-token');
370+
assert.dom('[data-test-api-token="1"] [data-test-token]').hasText(token.token);
371+
assert.dom('[data-test-api-token="1"] [data-test-endpoint-scopes]').hasText('Scopes: trusted-publishing');
372+
assert.dom('[data-test-api-token="1"] [data-test-crate-scopes]').doesNotExist();
373+
assert.dom('[data-test-api-token="1"] [data-test-expired-at]').doesNotExist();
374+
});
349375
});

0 commit comments

Comments
 (0)