From 0fe51622a6efbe1f0f23e55544829234baf5c0b6 Mon Sep 17 00:00:00 2001 From: Amal Hussein Date: Fri, 8 Nov 2019 18:36:45 -0500 Subject: [PATCH] feat: adding tests and updating docs to reflect changes in registry teams API. The default developers team can not longer be removed --- docs/content/cli-commands/npm-team.md | 7 +++---- test/tap/team.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/content/cli-commands/npm-team.md b/docs/content/cli-commands/npm-team.md index 3401dae26b369..87af3a8435ebe 100755 --- a/docs/content/cli-commands/npm-team.md +++ b/docs/content/cli-commands/npm-team.md @@ -29,12 +29,11 @@ handle permissions for packages. Teams must always be fully qualified with the organization/scope they belong to when operating on them, separated by a colon (`:`). That is, if you have a -`developers` team on a `foo` organization, you must always refer to that team as -`foo:developers` in these commands. +`wombats` team in a `wisdom` organization, you must always refer to that team as +`wisdom:wombats` in these commands. * create / destroy: - Create a new team, or destroy an existing one. - + Create a new team, or destroy an existing one. Note: You cannot remove the `developers` team, learn more. * add / rm: Add a user to an existing team, or remove a user from a team they belong to. diff --git a/test/tap/team.js b/test/tap/team.js index 939da45b77883..17acf82f4b231 100644 --- a/test/tap/team.js +++ b/test/tap/team.js @@ -88,6 +88,29 @@ test('team destroy', function (t) { }) }) +test('team destroy is not allowed for the default developers team', (t) => { + const teamData = { + name: 'developers', + scope_id: 1234, + created: '2015-07-23T18:07:49.959Z', + updated: '2015-07-23T18:07:49.959Z', + deleted: '2015-07-23T18:27:27.178Z' + } + server.delete('/-/team/myorg/' + teamData.name).reply(405, teamData) + common.npm([ + 'team', 'destroy', 'myorg:' + teamData.name, + '--registry', common.registry, + '--loglevel', 'silent', + '--json' + ], {}, function (err, code, stdout, stderr) { + t.ifError(err, 'npm team') + t.equal(code, 1, 'exited with code 1') + t.equal(stderr, '', 'no error output') + t.match(JSON.parse(stdout), {error: {code: 'E405'}}) + t.end() + }) +}) + test('team add', function (t) { var user = 'zkat' server.put('/-/team/myorg/myteam/user', JSON.stringify({