Skip to content

Commit d17c4b8

Browse files
Copilotaviadhahami
andcommitted
Add test verifying request URI has no double slashes with trailing-slash endpoint
Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/909d7cff-651f-47c2-b036-1f413bb6e575
1 parent 7e03e25 commit d17c4b8

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

test/unit.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,38 @@ describe('node-vault', () => {
111111
const vault = index(vaultConfig);
112112
vault.endpoint.should.equal('http://localhost:8200');
113113
});
114+
115+
it('should not produce double slashes in request URI when endpoint has trailing slash', (done) => {
116+
const request = sinon.stub();
117+
const response = sinon.stub();
118+
response.statusCode = 200;
119+
request.returns({
120+
then(fn) {
121+
return fn(response);
122+
},
123+
catch(fn) {
124+
return fn();
125+
},
126+
});
127+
128+
const vault = index({
129+
endpoint: 'http://localhost:8200/',
130+
token: '123',
131+
'request-promise': {
132+
defaults: () => request,
133+
},
134+
});
135+
136+
vault.read('secret/hello')
137+
.then(() => {
138+
request.should.have.calledOnce();
139+
const uri = request.firstCall.args[0].uri;
140+
uri.should.equal('http://localhost:8200/v1/secret/hello');
141+
uri.should.not.contain('//v1');
142+
done();
143+
})
144+
.catch(done);
145+
});
114146
});
115147

116148
describe('client', () => {

0 commit comments

Comments
 (0)