Skip to content

Commit

Permalink
feat: integrate checkCryptoImplementation into the main processing chain
Browse files Browse the repository at this point in the history
Signed-off-by: ChaitanyaD48 <[email protected]>
  • Loading branch information
ChaitanyaD48 committed Oct 27, 2024
1 parent bfc103f commit 681611f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/proxy/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const pushActionChain = [
proc.push.writePack,
proc.push.getDiff,
proc.push.clearBareClone,
proc.push.checkCryptoImplementation,
proc.push.scanDiff,
proc.push.blockForAuth,
];
Expand Down
9 changes: 9 additions & 0 deletions test/chain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const mockPushProcessors = {
audit: sinon.stub(),
checkRepoInAuthorisedList: sinon.stub(),
checkCommitMessages: sinon.stub(),
checkCryptoImplementation: sinon.stub(),
checkAuthorEmails: sinon.stub(),
checkUserPushPermission: sinon.stub(),
checkIfWaitingAuth: sinon.stub(),
Expand All @@ -33,6 +34,7 @@ mockPushProcessors.parsePush.displayName = 'parsePush';
mockPushProcessors.audit.displayName = 'audit';
mockPushProcessors.checkRepoInAuthorisedList.displayName = 'checkRepoInAuthorisedList';
mockPushProcessors.checkCommitMessages.displayName = 'checkCommitMessages';
mockPushProcessors.checkCryptoImplementation.displayName = 'checkCryptoImplementation';
mockPushProcessors.checkAuthorEmails.displayName = 'checkAuthorEmails';
mockPushProcessors.checkUserPushPermission.displayName = 'checkUserPushPermission';
mockPushProcessors.checkIfWaitingAuth.displayName = 'checkIfWaitingAuth';
Expand Down Expand Up @@ -106,6 +108,7 @@ describe('proxy chain', function () {
mockPushProcessors.checkCommitMessages.resolves(continuingAction);
mockPushProcessors.checkAuthorEmails.resolves(continuingAction);
mockPushProcessors.checkUserPushPermission.resolves(continuingAction);
mockPushProcessors.checkCryptoImplementation.resolves(continuingAction);

// this stops the chain from further execution
mockPushProcessors.checkIfWaitingAuth.resolves({ type: 'push', continue: () => false, allowPush: false });
Expand All @@ -120,6 +123,7 @@ describe('proxy chain', function () {
expect(mockPushProcessors.checkIfWaitingAuth.called).to.be.true;
expect(mockPushProcessors.pullRemote.called).to.be.false;
expect(mockPushProcessors.audit.called).to.be.true;
expect(mockPushProcessors.checkCryptoImplementation.called).to.be.true;

expect(result.type).to.equal('push');
expect(result.allowPush).to.be.false;
Expand All @@ -135,6 +139,8 @@ describe('proxy chain', function () {
mockPushProcessors.checkCommitMessages.resolves(continuingAction);
mockPushProcessors.checkAuthorEmails.resolves(continuingAction);
mockPushProcessors.checkUserPushPermission.resolves(continuingAction);
mockPushProcessors.checkCryptoImplementation.resolves(continuingAction);

// this stops the chain from further execution
mockPushProcessors.checkIfWaitingAuth.resolves({ type: 'push', continue: () => true, allowPush: true });
const result = await chain.executeChain(req);
Expand All @@ -148,6 +154,7 @@ describe('proxy chain', function () {
expect(mockPushProcessors.checkIfWaitingAuth.called).to.be.true;
expect(mockPushProcessors.pullRemote.called).to.be.false;
expect(mockPushProcessors.audit.called).to.be.true;
expect(mockPushProcessors.checkCryptoImplementation.called).to.be.true;

expect(result.type).to.equal('push');
expect(result.allowPush).to.be.true;
Expand All @@ -170,6 +177,7 @@ describe('proxy chain', function () {
mockPushProcessors.clearBareClone.resolves(continuingAction);
mockPushProcessors.scanDiff.resolves(continuingAction);
mockPushProcessors.blockForAuth.resolves(continuingAction);
mockPushProcessors.checkCryptoImplementation.resolves(continuingAction);

const result = await chain.executeChain(req);

Expand All @@ -187,6 +195,7 @@ describe('proxy chain', function () {
expect(mockPushProcessors.scanDiff.called).to.be.true;
expect(mockPushProcessors.blockForAuth.called).to.be.true;
expect(mockPushProcessors.audit.called).to.be.true;
expect(mockPushProcessors.checkCryptoImplementation.called).to.be.true;

expect(result.type).to.equal('push');
expect(result.allowPush).to.be.false;
Expand Down

0 comments on commit 681611f

Please sign in to comment.