|
@@ -20,7 +20,7 @@ describe('VEN registration', function() {
|
|
|
let venId, commonName, registrationResponse;
|
|
let venId, commonName, registrationResponse;
|
|
|
|
|
|
|
|
before(async () => {
|
|
before(async () => {
|
|
|
- venId = v4().replace(/-/g, '').substring(0,20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
|
|
|
|
+ venId = v4().replace(/-/g, '').substring(0, 20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
const requestId = v4().replace(/-/g, '');
|
|
const requestId = v4().replace(/-/g, '');
|
|
|
commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
|
const request = {
|
|
const request = {
|
|
@@ -36,12 +36,12 @@ describe('VEN registration', function() {
|
|
|
registrationResponse = await registerParty(request, commonName, venId);
|
|
registrationResponse = await registerParty(request, commonName, venId);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it ('allows registration of a new VEN', async () => {
|
|
|
|
|
|
|
+ it('allows registration of a new VEN', async () => {
|
|
|
expect(registrationResponse.registrationId).to.be.a('string');
|
|
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(':');
|
|
|
|
|
|
|
+ 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 requestId = v4().replace(/-/g, '');
|
|
|
const commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
const commonName = v4().replace(/-/g, '').substring(0, 12);
|
|
|
const request = {
|
|
const request = {
|
|
@@ -66,7 +66,7 @@ describe('VEN registration', function() {
|
|
|
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 () => {
|
|
|
|
|
|
|
+ it('rejects registration when common name changes', async () => {
|
|
|
const requestId = v4().replace(/-/g, '');
|
|
const requestId = v4().replace(/-/g, '');
|
|
|
const commonName2 = v4().replace(/-/g, '').substring(0, 12);
|
|
const commonName2 = v4().replace(/-/g, '').substring(0, 12);
|
|
|
const request = {
|
|
const request = {
|
|
@@ -91,9 +91,9 @@ describe('VEN registration', function() {
|
|
|
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 () => {
|
|
|
|
|
|
|
+ it('rejects registration with existing common name but different venId', async () => {
|
|
|
const requestId = v4().replace(/-/g, '');
|
|
const requestId = v4().replace(/-/g, '');
|
|
|
- const venId2 = v4().replace(/-/g, '').substring(0,20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
|
|
|
|
+ const venId2 = v4().replace(/-/g, '').substring(0, 20).toUpperCase().match(/.{2}/g).join(':');
|
|
|
|
|
|
|
|
const request = {
|
|
const request = {
|
|
|
requestId: requestId,
|
|
requestId: requestId,
|
|
@@ -116,50 +116,50 @@ describe('VEN registration', function() {
|
|
|
expect(exception).is.an('error');
|
|
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.');
|
|
|
});
|
|
});
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ describe('query', function() {
|
|
|
|
|
+
|
|
|
|
|
+ let venId, commonName, queryResponse;
|
|
|
|
|
+
|
|
|
|
|
+ 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
|
|
|
|
|
+ };
|
|
|
|
|
+ queryResponse = await query(request, commonName, venId);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- describe('query', function() {
|
|
|
|
|
-
|
|
|
|
|
- let venId, commonName, queryResponse;
|
|
|
|
|
-
|
|
|
|
|
- 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
|
|
|
|
|
- };
|
|
|
|
|
- queryResponse = await query(request, commonName, venId);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- it('does not return venId or registrationId for new device', async () => {
|
|
|
|
|
- expect(queryResponse.registrationId).to.be.undefined;
|
|
|
|
|
- expect(queryResponse.venId).to.be.undefined;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- it('returns registrationId if already registered', 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 registerRequest = {
|
|
|
|
|
- requestId: requestId,
|
|
|
|
|
- venId: venId,
|
|
|
|
|
- oadrProfileName: '2.0b',
|
|
|
|
|
- oadrTransportName: 'simplehttp',
|
|
|
|
|
- oadrReportOnly: false,
|
|
|
|
|
- oadrXmlSignature: false,
|
|
|
|
|
- oadrVenName: `VEN ${commonName}`,
|
|
|
|
|
- oadrHttpPullModel: true
|
|
|
|
|
- };
|
|
|
|
|
- registrationResponse = await registerParty(registerRequest, commonName, venId);
|
|
|
|
|
- const initialRegistrationId = registrationResponse.registrationId;
|
|
|
|
|
-
|
|
|
|
|
- const queryRequest = {
|
|
|
|
|
- requestId: requestId
|
|
|
|
|
- };
|
|
|
|
|
- queryResponse = await query(queryRequest, commonName, venId);
|
|
|
|
|
- expect(queryResponse.registrationId).to.eql(initialRegistrationId);
|
|
|
|
|
- expect(queryResponse.venId).to.eql(venId);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ it('does not return venId or registrationId for new device', async () => {
|
|
|
|
|
+ expect(queryResponse.registrationId).to.be.undefined;
|
|
|
|
|
+ expect(queryResponse.venId).to.be.undefined;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('returns registrationId if already registered', 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 registerRequest = {
|
|
|
|
|
+ requestId: requestId,
|
|
|
|
|
+ venId: venId,
|
|
|
|
|
+ oadrProfileName: '2.0b',
|
|
|
|
|
+ oadrTransportName: 'simplehttp',
|
|
|
|
|
+ oadrReportOnly: false,
|
|
|
|
|
+ oadrXmlSignature: false,
|
|
|
|
|
+ oadrVenName: `VEN ${commonName}`,
|
|
|
|
|
+ oadrHttpPullModel: true
|
|
|
|
|
+ };
|
|
|
|
|
+ const registrationResponse = await registerParty(registerRequest, commonName, venId);
|
|
|
|
|
+ const initialRegistrationId = registrationResponse.registrationId;
|
|
|
|
|
+
|
|
|
|
|
+ const queryRequest = {
|
|
|
|
|
+ requestId: requestId
|
|
|
|
|
+ };
|
|
|
|
|
+ queryResponse = await query(queryRequest, commonName, venId);
|
|
|
|
|
+ expect(queryResponse.registrationId).to.eql(initialRegistrationId);
|
|
|
|
|
+ expect(queryResponse.venId).to.eql(venId);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|