diff --git a/javascript/lib/api/tests/client/http/features.http.spec.ts b/javascript/lib/api/tests/client/http/features.http.spec.ts index 3e99739c..e1648526 100644 --- a/javascript/lib/api/tests/client/http/features.http.spec.ts +++ b/javascript/lib/api/tests/client/http/features.http.spec.ts @@ -89,7 +89,7 @@ describe('Http Features Handle', () => { }); }); - it('updates a Feature', () => { + it('creates a Feature', () => { return H.test({ toTest: () => handle.putFeature(H.feature), testBody: H.feature.toObject(), @@ -101,6 +101,18 @@ describe('Http Features Handle', () => { }); }); + it('updates a Feature', () => { + return H.test({ + toTest: () => handle.putFeature(H.feature), + testBody: H.feature.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/${H.feature.id}`, + method: 'put', + status: 204, + payload: H.feature.toJson() + }); + }); + it('updates a Definition', () => { return H.test({ toTest: () => handle.putDefinition(H.feature.id, H.definition), diff --git a/javascript/lib/api/tests/client/http/http-requester.mock.ts b/javascript/lib/api/tests/client/http/http-requester.mock.ts index c8d4c4b8..92fca212 100644 --- a/javascript/lib/api/tests/client/http/http-requester.mock.ts +++ b/javascript/lib/api/tests/client/http/http-requester.mock.ts @@ -28,6 +28,7 @@ export class TestRequester implements HttpRequester { } this.requests.forEach((response, request) => { if (this.matches(method, url, header, body, request)) { + this.requests.delete(request); resolve(response); } }); diff --git a/javascript/lib/api/tests/client/http/policies.http.spec.ts b/javascript/lib/api/tests/client/http/policies.http.spec.ts index 29945ef6..54d8ade3 100644 --- a/javascript/lib/api/tests/client/http/policies.http.spec.ts +++ b/javascript/lib/api/tests/client/http/policies.http.spec.ts @@ -123,7 +123,7 @@ describe('Http Policies Handle', () => { }); }); - it('puts a Policy', () => { + it('creates a Policy', () => { return H.test({ toTest: () => handle.putPolicy(policy), testBody: policy.toObject(), @@ -135,6 +135,30 @@ describe('Http Policies Handle', () => { }); }); + it('updates a Policy', () => { + return H.test({ + toTest: () => handle.putPolicy(policy), + testBody: policy.toObject(), + expected: new PutResponse(null, 204, undefined), + request: baseRequest, + method: 'put', + status: 204, + payload: policy.toJson() + }); + }); + + it('creates Entries', () => { + return H.test({ + toTest: () => handle.putEntries(policy.id, entries), + testBody: Entries.toObject(entries), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries`, + method: 'put', + status: 204, + payload: Entries.toJson(entries) + }); + }); + it('updates Entries', () => { return H.test({ toTest: () => handle.putEntries(policy.id, entries), @@ -147,7 +171,7 @@ describe('Http Policies Handle', () => { }); }); - it('updates an Entry', () => { + it('creates an Entry', () => { return H.test({ toTest: () => handle.putEntry(policy.id, anEntry), testBody: anEntry.toObject(), @@ -159,7 +183,19 @@ describe('Http Policies Handle', () => { }); }); - it('updates Subjects', () => { + it('updates an Entry', () => { + return H.test({ + toTest: () => handle.putEntry(policy.id, anEntry), + testBody: anEntry.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries/${label}`, + method: 'put', + status: 204, + payload: anEntry.toJson() + }); + }); + + it('creates Subjects', () => { return H.test({ toTest: () => handle.putSubjects(policy.id, label, subjects), testBody: Subjects.toObject(subjects), @@ -171,7 +207,19 @@ describe('Http Policies Handle', () => { }); }); - it('updates a Subject', () => { + it('updates Subjects', () => { + return H.test({ + toTest: () => handle.putSubjects(policy.id, label, subjects), + testBody: Subjects.toObject(subjects), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries/${label}/subjects`, + method: 'put', + status: 204, + payload: Subjects.toJson(subjects) + }); + }); + + it('creates a Subject', () => { return H.test({ toTest: () => handle.putSubject(policy.id, label, aSubject), testBody: aSubject.toObject(), @@ -183,7 +231,19 @@ describe('Http Policies Handle', () => { }); }); - it('updates Resources', () => { + it('updates a Subject', () => { + return H.test({ + toTest: () => handle.putSubject(policy.id, label, aSubject), + testBody: aSubject.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries/${label}/subjects/${subjectId}`, + method: 'put', + status: 204, + payload: aSubject.toJson() + }); + }); + + it('creates Resources', () => { return H.test({ toTest: () => handle.putResources(policy.id, label, resources), testBody: Resources.toObject(resources), @@ -195,7 +255,19 @@ describe('Http Policies Handle', () => { }); }); - it('updates a Resource', () => { + it('updates Resources', () => { + return H.test({ + toTest: () => handle.putResources(policy.id, label, resources), + testBody: Resources.toObject(resources), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries/${label}/resources`, + method: 'put', + status: 204, + payload: Resources.toJson(resources) + }); + }); + + it('creates a Resource', () => { return H.test({ toTest: () => handle.putResource(policy.id, label, aResource), testBody: aResource.toObject(), @@ -207,6 +279,18 @@ describe('Http Policies Handle', () => { }); }); + it('updates a Resource', () => { + return H.test({ + toTest: () => handle.putResource(policy.id, label, aResource), + testBody: aResource.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/entries/${label}/resources/${resourcePath}`, + method: 'put', + status: 204, + payload: aResource.toJson() + }); + }); + it('deletes a Policy', () => { return H.test({ toTest: () => handle.deletePolicy(policy.id), diff --git a/javascript/lib/api/tests/client/http/things.http.spec.ts b/javascript/lib/api/tests/client/http/things.http.spec.ts index 6698700a..e06f077d 100644 --- a/javascript/lib/api/tests/client/http/things.http.spec.ts +++ b/javascript/lib/api/tests/client/http/things.http.spec.ts @@ -145,7 +145,7 @@ describe('Http Things Handle', () => { }); }); - it('puts a Thing', () => { + it('puts a new Thing', () => { return H.test({ toTest: () => handleV2.putThing(H.thing), testBody: H.thing.toObject(), @@ -157,6 +157,18 @@ describe('Http Things Handle', () => { }); }); + it('puts a Thing that already exists', () => { + return H.test({ + toTest: () => handleV2.putThing(H.thing), + testBody: H.thing.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}`, + method: 'put', + status: 204, + payload: H.thing.toJson() + }); + }); + it('updates a policyId', () => { return H.test({ toTest: () => handleV2.putPolicyId(H.thing.thingId, 'ID'), @@ -169,7 +181,7 @@ describe('Http Things Handle', () => { }); }); - it('updates an Attribute', () => { + it('creates Attributes', () => { return H.test({ toTest: () => handleV2.putAttributes(H.thing.thingId, H.attributes), testBody: H.attributes, @@ -181,7 +193,19 @@ describe('Http Things Handle', () => { }); }); - it('updates an Attribute', () => { + it('updates Attributes', () => { + return H.test({ + toTest: () => handleV2.putAttributes(H.thing.thingId, H.attributes), + testBody: H.attributes, + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/attributes`, + method: 'put', + status: 204, + payload: JSON.stringify(H.attributes) + }); + }); + + it('creates an Attribute', () => { return H.test({ toTest: () => handleV2.putAttribute(H.thing.thingId, H.attributePath, H.attribute), testBody: H.attribute, @@ -204,7 +228,7 @@ describe('Http Things Handle', () => { }); }); - it('updates an AclEntry', () => { + it('creates an AclEntry', () => { return H.test({ toTest: () => handleV1.putAclEntry(H.thing.thingId, anAclEntry), testBody: anAclEntry.toObject(), @@ -217,6 +241,19 @@ describe('Http Things Handle', () => { }); }); + it('updates an AclEntry', () => { + return H.test({ + toTest: () => handleV1.putAclEntry(H.thing.thingId, anAclEntry), + testBody: anAclEntry.toObject(), + expected: new PutResponse(null, 204, undefined), + request: `${baseRequest}/acl/${authorizationSubject}`, + method: 'put', + status: 204, + payload: anAclEntry.toJson(), + api: 1 + }); + }); + it('deletes a Thing', () => { return H.test({ toTest: () => handleV2.deleteThing(H.thing.thingId),