| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- 'use strict';
- const { expect } = require('chai');
- const { v4 } = require('uuid');
- const { sequelize } = require('../../../db');
- const {
- registerParty,
- } = require('../../../processes/registration');
- describe('VEN registration', function() {
- before(async () => {
- await sequelize.sync();
- });
- describe('registerParty', function() {
- let venId, commonName, registrationResponse;
- before(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 ('allows registration of a new VEN', async () => {
- expect(registrationResponse.registrationId).to.be.a('string');
- });
- it ('rejects VEN with non-matching venId', async () => {
- const venId = v4().replace(/-/g, '').substring(0,20).toUpperCase().match(/.{2}/g).join(':');
- const requestId = v4().replace(/-/g, '');
- const 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
- };
- let exception;
- try {
- await registerParty(request, commonName, `${venId}:FF`);
- } catch (e) {
- exception = e;
- }
- expect(exception).is.an('error');
- expect(exception.message).to.eql('VenID does not match certificate.');
- });
- it ('rejects registration when common name changes', async () => {
- const requestId = v4().replace(/-/g, '');
- const commonName2 = 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
- };
- let exception;
- try {
- await registerParty(request, commonName2, venId);
- } catch (e) {
- exception = e;
- }
- expect(exception).is.an('error');
- expect(exception.message).to.eql('Client certificate CN mismatch.');
- });
- it ('rejects registration with existing common name but different venId', async () => {
- const requestId = v4().replace(/-/g, '');
- const venId2 = v4().replace(/-/g, '').substring(0,20).toUpperCase().match(/.{2}/g).join(':');
- const request = {
- requestId: requestId,
- venId: venId2,
- oadrProfileName: '2.0b',
- oadrTransportName: 'simplehttp',
- oadrReportOnly: false,
- oadrXmlSignature: false,
- oadrVenName: `VEN ${commonName}`,
- oadrHttpPullModel: true
- };
- let exception;
- try {
- await registerParty(request, commonName, venId2);
- } catch (e) {
- exception = e;
- }
- expect(exception).is.an('error');
- expect(exception.message).to.eql('Ven already exists with that CN.');
- });
- });
- });
|