Sanitize personal tokens from custom background imagery

(closes #6801)
This commit is contained in:
Bryan Housel
2020-03-14 10:30:46 -04:00
parent 94c9697ee4
commit 47aaec0db6
2 changed files with 47 additions and 2 deletions
+26
View File
@@ -70,3 +70,29 @@ describe('iD.rendererBackgroundSource', function() {
expect(source.validZoom(17)).to.be.false;
});
});
describe('iD.rendererBackgroundSource.Custom', function() {
describe('#imageryUsed', function() {
it('returns an imagery_used string', function() {
var source = iD.rendererBackgroundSource.Custom('http://example.com');
expect(source.imageryUsed()).to.eql('Custom (http://example.com )'); // note ' )' space
});
it('sanitizes `access_token`', function() {
var source = iD.rendererBackgroundSource.Custom('http://example.com?access_token=MYTOKEN');
expect(source.imageryUsed()).to.eql('Custom (http://example.com?access_token={apikey} )');
});
it('sanitizes `connectId`', function() {
var source = iD.rendererBackgroundSource.Custom('http://example.com?connectId=MYTOKEN');
expect(source.imageryUsed()).to.eql('Custom (http://example.com?connectId={apikey} )');
});
it('sanitizes `token`', function() {
var source = iD.rendererBackgroundSource.Custom('http://example.com?token=MYTOKEN');
expect(source.imageryUsed()).to.eql('Custom (http://example.com?token={apikey} )');
});
it('sanitizes wms path `token`', function() {
var source = iD.rendererBackgroundSource.Custom('http://example.com/wms/v1/token/MYTOKEN/1.0.0/layer');
expect(source.imageryUsed()).to.eql('Custom (http://example.com/wms/v1/token/{apikey}/1.0.0/layer )');
});
});
});