Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('AddCertificateComponent', () => {
component['fileType'].should.equal(type);
});

it('should set the cetificate string to the dataBuffer string content', async(() => {
it('should set the certificate string to the dataBuffer string content', async(() => {
let data = 'someData';
component.createCertificate('', data);
component['addedCertificate'].should.equal(data);
Expand Down Expand Up @@ -242,13 +242,58 @@ describe('AddCertificateComponent', () => {
mockModalSpy.should.have.been.called;
}));

it('should handle strings with encoded newlines (windows format 1) in certs correctly', async(() => {

component['addedCertificate'] = 'MuchCertificate\\r\\nFollowon\\r\\nFinal';
component['addedHostname'] = 'suchHost';

let additionalData = {};
additionalData['cert'] = 'MuchCertificate\nFollowon\nFinal';
additionalData['hostnameOverride'] = 'suchHost';

// call the method
component.addCertificate();

mockModalSpy.should.have.been.calledWith(additionalData);
}));

it('should handle strings with encoded newlines (windows format 2) in certs correctly', async(() => {

component['addedCertificate'] = 'MuchCertificate\\n\\rFollowon\\n\\rFinal';
component['addedHostname'] = 'suchHost';

let additionalData = {};
additionalData['cert'] = 'MuchCertificate\nFollowon\nFinal';
additionalData['hostnameOverride'] = 'suchHost';

// call the method
component.addCertificate();

mockModalSpy.should.have.been.calledWith(additionalData);
}));

it('should handle strings with encoded newlines (unix format) in certs correctly', async(() => {

component['addedCertificate'] = 'MuchCertificate\\nFollowon\\nFinal';
component['addedHostname'] = 'suchHost';

let additionalData = {};
additionalData['cert'] = 'MuchCertificate\nFollowon\nFinal';
additionalData['hostnameOverride'] = 'suchHost';

// call the method
component.addCertificate();

mockModalSpy.should.have.been.calledWith(additionalData);
}));

it('should return a constructed json object', async(() => {

component['addedCertificate'] = 'MuchCertificate';
component['addedHostname'] = 'suchHost';

let additionalData = {};
additionalData['cert'] = 'MuchCertificate'.replace(/[\\n\\r]/g, '');
additionalData['cert'] = 'MuchCertificate';
additionalData['hostnameOverride'] = 'suchHost';

// call the method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class AddCertificateComponent {
addCertificate(): void {
let additionalData = {};
additionalData['hostnameOverride'] = this.addedHostname;
additionalData['cert'] = this.addedCertificate.replace(/[\\n\\r]/g, '');
additionalData['cert'] = this.addedCertificate.replace(/\\r\\n|\\n\\r|\\n/g, '\n');
this.activeModal.close(additionalData);
}
}