|
|
@@ -5,6 +5,7 @@ const { v4 } = require('uuid');
|
|
|
const { sequelize } = require('../../../db');
|
|
|
|
|
|
const {
|
|
|
+ cancelParty,
|
|
|
query,
|
|
|
registerParty,
|
|
|
} = require('../../../processes/registration');
|
|
|
@@ -19,7 +20,7 @@ describe('VEN registration', function() {
|
|
|
|
|
|
let venId, commonName, registrationResponse;
|
|
|
|
|
|
- before(async () => {
|
|
|
+ beforeEach(async () => {
|
|
|
venId = v4().replace(/-/g, '').substring(0, 20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
const requestId = v4().replace(/-/g, '');
|
|
|
commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
|
@@ -63,7 +64,7 @@ describe('VEN registration', function() {
|
|
|
}
|
|
|
|
|
|
expect(exception).is.an('error');
|
|
|
- expect(exception.message).to.eql('VenID does not match certificate.');
|
|
|
+ expect(exception.message).to.eql('VenID does not match certificate');
|
|
|
});
|
|
|
|
|
|
it('rejects registration when common name changes', async () => {
|
|
|
@@ -88,7 +89,7 @@ describe('VEN registration', function() {
|
|
|
}
|
|
|
|
|
|
expect(exception).is.an('error');
|
|
|
- expect(exception.message).to.eql('Client certificate CN mismatch.');
|
|
|
+ expect(exception.message).to.eql('Client certificate CN mismatch');
|
|
|
});
|
|
|
|
|
|
it('rejects registration with existing common name but different venId', async () => {
|
|
|
@@ -114,7 +115,7 @@ describe('VEN registration', function() {
|
|
|
}
|
|
|
|
|
|
expect(exception).is.an('error');
|
|
|
- expect(exception.message).to.eql('Ven already exists with that CN.');
|
|
|
+ expect(exception.message).to.eql('Ven already exists with that CN');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -122,7 +123,7 @@ describe('VEN registration', function() {
|
|
|
|
|
|
let venId, commonName, queryResponse;
|
|
|
|
|
|
- before(async () => {
|
|
|
+ beforeEach(async () => {
|
|
|
venId = v4().replace(/-/g, '').substring(0, 20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
const requestId = v4().replace(/-/g, '');
|
|
|
commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
|
@@ -162,4 +163,99 @@ describe('VEN registration', function() {
|
|
|
expect(queryResponse.venId).to.eql(venId);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('cancelParty', function() {
|
|
|
+
|
|
|
+ let venId, commonName, registrationResponse;
|
|
|
+
|
|
|
+ beforeEach(async () => {
|
|
|
+ venId = v4().replace(/-/g, '').substring(0, 20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
+ const requestId = v4().replace(/-/g, '');
|
|
|
+ commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
|
+ const request = {
|
|
|
+ requestId: requestId,
|
|
|
+ venId: venId,
|
|
|
+ oadrProfileName: '2.0b',
|
|
|
+ oadrTransportName: 'simplehttp',
|
|
|
+ oadrReportOnly: false,
|
|
|
+ oadrXmlSignature: false,
|
|
|
+ oadrVenName: `VEN ${commonName}`,
|
|
|
+ oadrHttpPullModel: true
|
|
|
+ };
|
|
|
+ registrationResponse = await registerParty(request, commonName, venId);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('successfully cancels an existing registration', async () => {
|
|
|
+ const cancelRequestId = v4().replace(/-/g, '');
|
|
|
+ const cancelRequest = {
|
|
|
+ requestId: cancelRequestId,
|
|
|
+ registrationId: registrationResponse.registrationId,
|
|
|
+ venId: venId
|
|
|
+ };
|
|
|
+
|
|
|
+ const cancelResponse = await cancelParty(cancelRequest, commonName, venId);
|
|
|
+ expect(cancelResponse.responseCode).to.eql('200');
|
|
|
+ expect(cancelResponse.responseDescription).to.eql('OK');
|
|
|
+ expect(cancelResponse.responseRequestId).to.eql(cancelRequestId);
|
|
|
+ expect(cancelResponse.venId).to.eql(venId);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('fails if no registrationId is specified', async () => {
|
|
|
+ const cancelRequestId = v4().replace(/-/g, '');
|
|
|
+ const cancelRequest = {
|
|
|
+ requestId: cancelRequestId,
|
|
|
+ venId: venId
|
|
|
+ };
|
|
|
+
|
|
|
+ let error;
|
|
|
+ try {
|
|
|
+ await cancelParty(cancelRequest, commonName, venId);
|
|
|
+ } catch (e) {
|
|
|
+ error = e;
|
|
|
+ }
|
|
|
+ expect(error).to.be.an('error');
|
|
|
+ expect(error.message).to.eql('No registrationID in request');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('fails if venID does not match certificate', async () => {
|
|
|
+ const otherVenId = v4().replace(/-/g, '');
|
|
|
+ const cancelRequestId = v4().replace(/-/g, '');
|
|
|
+ const cancelRequest = {
|
|
|
+ requestId: cancelRequestId,
|
|
|
+ registrationId: registrationResponse.registrationId,
|
|
|
+ venId: venId
|
|
|
+ };
|
|
|
+
|
|
|
+ let error;
|
|
|
+ try {
|
|
|
+ await cancelParty(cancelRequest, commonName, otherVenId);
|
|
|
+ } catch (e) {
|
|
|
+ error = e;
|
|
|
+ }
|
|
|
+ expect(error).to.be.an('error');
|
|
|
+ expect(error.message).to.eql('VenID does not match certificate');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('fails if no current registration to cancel', async () => {
|
|
|
+ const cancelRequestId = v4().replace(/-/g, '');
|
|
|
+ const cancelRequest = {
|
|
|
+ requestId: cancelRequestId,
|
|
|
+ registrationId: registrationResponse.registrationId,
|
|
|
+ venId: venId
|
|
|
+ };
|
|
|
+
|
|
|
+ // first cancellation
|
|
|
+ await cancelParty(cancelRequest, commonName, venId);
|
|
|
+
|
|
|
+ let error;
|
|
|
+ try {
|
|
|
+ // second cancellation
|
|
|
+ await cancelParty(cancelRequest, commonName, venId);
|
|
|
+ } catch (e) {
|
|
|
+ error = e;
|
|
|
+ }
|
|
|
+ expect(error).to.be.an('error');
|
|
|
+ expect(error.message).to.eql('No current registration for VenID');
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|