Skip to content

Commit

Permalink
addressed testing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AJun01 committed Aug 20, 2024
1 parent 234b4b9 commit 7c854da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function request(options,cb){
}else{
_options=options;
}
if (anonymizer.isAnonymizationEnabled) {
if (anonymizer.isAnonymizationEnabled()) {
_options = anonymizer.anonymizeRequest(_options);
}
let protocol;
Expand All @@ -427,7 +427,7 @@ function request(options,cb){
});

if (cb) {
if(anonymizer.isAnonymizationEnabled) {
if(anonymizer.isAnonymizationEnabled()) {
cb(anonymizer.anonymizeResponse(response));
}else {
cb(response)
Expand Down
9 changes: 8 additions & 1 deletion test/anonymized-form-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
var assert = require("assert"),
should = require('should'),
{ anonymizeFormData, setAnonymization } = require('../lib/anonymizer'),
{ anonymizeFormData, setAnonymization, isAnonymizationEnabled } = require('../lib/anonymizer'),
stream = require('stream');

describe('Anonymization Tests for Form Data', () => {

before(function() {
if (!isAnonymizationEnabled()) {
this.skip();
}
});

it('should anonymize form data', (done) => {
const formData = `--boundary123\r\nContent-Disposition: form-data; name="first_name"\r\n\r\nJohn\r\n--boundary123\r\nContent-Disposition: form-data; name="last_name"\r\n\r\nDoe\r\n--boundary123\r\nContent-Disposition: form-data; name="email"\r\n\r\[email protected]\r\n--boundary123\r\nContent-Disposition: form-data; name="password"\r\n\r\nsecurepassword123\r\n--boundary123\r\nContent-Disposition: form-data; name="profile_picture"; filename="profile.jpg"\r\nContent-Type: image/jpeg\r\n\r\n<binary data of profile.jpg>\r\n--boundary123--\r\n`;

Expand Down
8 changes: 7 additions & 1 deletion test/anonymized-json-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var assert = require("assert"),
should = require('should'),
{ anonymizeObject, setAnonymization } = require('../lib/anonymizer');
{ anonymizeObject, setAnonymization, isAnonymizationEnabled } = require('../lib/anonymizer');

describe('Anonymization Tests for JSON Data', () => {
const exampleJson = {
Expand Down Expand Up @@ -60,6 +60,12 @@ describe('Anonymization Tests for JSON Data', () => {
]
};

before(function() {
if (!isAnonymizationEnabled()) {
this.skip();
}
});

it('should anonymize the email', () => {
const anonymizedJson = anonymizeObject({ ...exampleJson });
anonymizedJson.email.should.equal('[email protected]');
Expand Down

0 comments on commit 7c854da

Please sign in to comment.