Skip to content

Commit

Permalink
failing/skipped test for client audit purge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Sep 9, 2024
1 parent 2fec9b0 commit e475cd2
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions test/integration/other/submission-purging.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { sql } = require('slonik');
const { testService } = require('../setup');
const testData = require('../../data/xml');
const should = require('should');
const { createReadStream } = require('fs');

const appPath = require('app-root-path');
const { exhaust } = require(appPath + '/lib/worker/worker');
Expand Down Expand Up @@ -331,18 +332,53 @@ describe('query module submission purge', () => {
});
}));

// TODO check soft-deleted submissions
// should not be accessible
// should not show up in any export
// should not show up in odata
// should interact with pagination and skip tokens
// TODO: test doesn't pass because of client audit purging bug
it.skip('should purge client audit blobs attachments for a deleted submission', testService(async (service, container) => {
const asAlice = await service.login('alice');

// Create the form
await asAlice.post('/v1/projects/1/forms?publish=true')
.send(testData.forms.clientAudits)
.expect(200);

// Send the submission with the client audit attachment
await asAlice.post('/v1/projects/1/submission')
.set('X-OpenRosa-Version', '1.0')
.attach('audit.csv', createReadStream(appPath + '/test/data/audit.csv'), { filename: 'audit.csv' })
.attach('xml_submission_file', Buffer.from(testData.instances.clientAudits.one), { filename: 'data.xml' })
.expect(201)

Check failure on line 349 in test/integration/other/submission-purging.js

View workflow job for this annotation

GitHub Actions / standard-tests

Missing semicolon

// Process the client audit attachment
await exhaust(container);

// Check that the client audit events are in the database
const clientAuditEventCount = await container.oneFirst(sql`select count(*) from client_audits group by "blobId"`);
clientAuditEventCount.should.equal(5); // 1 blob with 5 events in it

// Check that the blobs are in the database
const numBlobs = await container.oneFirst(sql`select count(*) from blobs`);
numBlobs.should.equal(1);

// Delete the submission
await asAlice.delete('/v1/projects/1/forms/clientAudits/submissions/one');

// Purge the submission
await container.Submissions.purge(true);

// Check that the client audit events are deleted from the database
const numClientAudits = await container.oneFirst(sql`select count(*) from client_audits`);
numClientAudits.should.equal(0);

// Check that the blobs are deleted from the database
const count = await container.oneFirst(sql`select count(*) from blobs`);
count.should.equal(0);
}));

// TODO other stuff
// should not delete a draft submission? or yes?
// should purge client audits associated with a submission via attachment

// TODO in purge function
// redact audit notes
// decide there should be no actee id in the submission.purge audit log because it could be across forms or projects
// purge by specific thing like project,xmlFormId,instanceId
// add cli thing to do this
Expand Down

0 comments on commit e475cd2

Please sign in to comment.