Skip to content

Commit ae7d3d4

Browse files
zxan1285Drew Fyock
authored and
Drew Fyock
committed
calcChanges for resourceServers by 'identifier' (auth0#69)
* calcChanges for resourceServers by 'identifier' * tests
1 parent 472ea90 commit ae7d3d4

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auth0-source-control-extension-tools",
3-
"version": "3.4.1",
3+
"version": "3.4.2",
44
"description": "Supporting tools for the Source Control extensions",
55
"main": "lib/index.js",
66
"scripts": {

src/auth0/handlers/resourceServers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default class ResourceServersHandler extends DefaultHandler {
6767
resourceServers = resourceServers.filter(r => !excluded.includes(r.name));
6868
existing = existing.filter(r => !excluded.includes(r.name));
6969

70-
return calcChanges(resourceServers, existing, [ 'id', 'name' ]);
70+
return calcChanges(resourceServers, existing, [ 'id', 'identifier' ]);
7171
}
7272

7373
async validate(assets) {

tests/auth0/handlers/resourceServers.tests.js

+27
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,33 @@ describe('#resourceServers handler', () => {
130130
await stageFn.apply(handler, [ { resourceServers: [ { name: 'someAPI', identifier: 'some-api', scope: 'new:scope' } ] } ]);
131131
});
132132

133+
it('should create new resource server with same name but different identifier', async () => {
134+
const auth0 = {
135+
resourceServers: {
136+
create: (data) => {
137+
expect(data).to.be.an('object');
138+
expect(data.name).to.equal('someAPI');
139+
expect(data.scope).to.equal('new:scope');
140+
expect(data.identifier).to.equal('another-api');
141+
return Promise.resolve(data);
142+
},
143+
update: (params, data) => {
144+
expect(params).to.be('undefined');
145+
expect(data).to.be('undefined');
146+
return Promise.resolve(data);
147+
},
148+
delete: () => Promise.resolve([]),
149+
getAll: () => [ { id: 'rs1', identifier: 'some-api', name: 'someAPI' } ]
150+
},
151+
pool
152+
};
153+
154+
const handler = new resourceServers.default({ client: auth0, config });
155+
const stageFn = Object.getPrototypeOf(handler).processChanges;
156+
157+
await stageFn.apply(handler, [ { resourceServers: [ { name: 'someAPI', identifier: 'another-api', scope: 'new:scope' } ] } ]);
158+
});
159+
133160
it('should remove resource server', async () => {
134161
const auth0 = {
135162
resourceServers: {

0 commit comments

Comments
 (0)