|
| 1 | +const fc = require('fast-check'); |
1 | 2 | const chai = require('chai');
|
2 | 3 | const sinon = require('sinon');
|
3 | 4 | const proxyquire = require('proxyquire').noCallThru();
|
@@ -93,4 +94,47 @@ describe('blockForAuth', () => {
|
93 | 94 | expect(message).to.include('/push/push@special#chars!');
|
94 | 95 | });
|
95 | 96 | });
|
| 97 | + |
| 98 | + describe.only('fuzzing', () => { |
| 99 | + it('should handle all possible characters in action ID', () => { |
| 100 | + fc.assert( |
| 101 | + fc.property(fc.string(), (actionId) => { |
| 102 | + action.id = actionId; |
| 103 | + exec(req, action); |
| 104 | + }) |
| 105 | + ); |
| 106 | + }); |
| 107 | + |
| 108 | + it('should create a step with correct parameters regardless of action ID', () => { |
| 109 | + fc.assert( |
| 110 | + fc.asyncProperty(fc.string(), async (actionId) => { |
| 111 | + action.id = actionId; |
| 112 | + |
| 113 | + const freshStepInstance = new Step('temp'); |
| 114 | + const setAsyncBlockStub = sinon.stub(freshStepInstance, 'setAsyncBlock'); |
| 115 | + |
| 116 | + const StepSpyLocal = sinon.stub().returns(freshStepInstance); |
| 117 | + const getServiceUIURLStubLocal = sinon.stub().returns('http://localhost:8080'); |
| 118 | + |
| 119 | + const blockForAuth = proxyquire('../../src/proxy/processors/push-action/blockForAuth', { |
| 120 | + '../../../service/urls': { getServiceUIURL: getServiceUIURLStubLocal }, |
| 121 | + '../../actions': { Step: StepSpyLocal } |
| 122 | + }); |
| 123 | + |
| 124 | + const result = await blockForAuth.exec(req, action); |
| 125 | + |
| 126 | + expect(StepSpyLocal.calledOnce).to.be.true; |
| 127 | + expect(StepSpyLocal.calledWithExactly('authBlock')).to.be.true; |
| 128 | + expect(setAsyncBlockStub.calledOnce).to.be.true; |
| 129 | + |
| 130 | + const message = setAsyncBlockStub.firstCall.args[0]; |
| 131 | + expect(message).to.include(`http://localhost:8080/dashboard/push/${actionId}`); |
| 132 | + expect(message).to.include('\x1B[32mGitProxy has received your push ✅\x1B[0m'); |
| 133 | + expect(message).to.include(`\x1B[34mhttp://localhost:8080/dashboard/push/${actionId}\x1B[0m`); |
| 134 | + expect(message).to.include('🔗 Shareable Link'); |
| 135 | + expect(result).to.equal(action); |
| 136 | + }) |
| 137 | + ); |
| 138 | + }); |
| 139 | + }); |
96 | 140 | });
|
0 commit comments