Merge branch 'master' into jose-version-update
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
# @backstage/backend-common
|
||||
|
||||
## 0.13.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 19f6c6c32a: The backend will no longer fail to start up when configured secrets do not match the configuration schema.
|
||||
- b7436743cb: Added the GerritUrlReader that implements "readUrl".
|
||||
- 3ef123bbf0: Support external ID when assuming roles in S3 integration
|
||||
|
||||
In order to assume a role created by a 3rd party as external
|
||||
ID is needed. This change adds an optional field to the s3
|
||||
integration configuration and consumes that in the AwsS3UrlReader.
|
||||
|
||||
- bae9359032: The logger returned from `getVoidLogger` is now uses a silenced console transport instead.
|
||||
- 3ff0e79654: Tweaked the `UrlReader` multiplexer so that it uses the more helpful `NotAllowedError` messaging for all methods.
|
||||
- 12608f8ba8: Add `@types/webpack-env` to dependencies.
|
||||
- f9f512559b: Updated the visibility of database connection fields in config to be secret
|
||||
- Updated dependencies
|
||||
- @backstage/integration@1.1.0
|
||||
- @backstage/config-loader@1.1.0
|
||||
|
||||
## 0.13.2-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@backstage/backend-common",
|
||||
"description": "Common functionality library for Backstage backends",
|
||||
"version": "0.13.2-next.2",
|
||||
"version": "0.13.2",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"private": false,
|
||||
@@ -36,9 +36,9 @@
|
||||
"dependencies": {
|
||||
"@backstage/cli-common": "^0.1.8",
|
||||
"@backstage/config": "^1.0.0",
|
||||
"@backstage/config-loader": "^1.1.0-next.1",
|
||||
"@backstage/config-loader": "^1.1.0",
|
||||
"@backstage/errors": "^1.0.0",
|
||||
"@backstage/integration": "^1.1.0-next.2",
|
||||
"@backstage/integration": "^1.1.0",
|
||||
"@backstage/types": "^1.0.0",
|
||||
"@google-cloud/storage": "^5.8.0",
|
||||
"@manypkg/get-packages": "^1.1.3",
|
||||
@@ -90,8 +90,8 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/backend-test-utils": "^0.1.23-next.1",
|
||||
"@backstage/cli": "^0.17.0-next.3",
|
||||
"@backstage/backend-test-utils": "^0.1.23",
|
||||
"@backstage/cli": "^0.17.0",
|
||||
"@types/archiver": "^5.1.0",
|
||||
"@types/compression": "^1.7.0",
|
||||
"@types/concat-stream": "^2.0.0",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2020 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getVoidLogger } from '../logging';
|
||||
import { UrlReaderPredicateMux } from './UrlReaderPredicateMux';
|
||||
|
||||
describe('UrlReaderPredicateMux', () => {
|
||||
it('forwards methods based on predicate', async () => {
|
||||
const fooReader = {
|
||||
read: jest.fn(),
|
||||
readUrl: jest.fn(),
|
||||
readTree: jest.fn(),
|
||||
search: jest.fn(),
|
||||
};
|
||||
const barReader = {
|
||||
read: jest.fn(),
|
||||
readUrl: jest.fn(),
|
||||
readTree: jest.fn(),
|
||||
search: jest.fn(),
|
||||
};
|
||||
|
||||
const mux = new UrlReaderPredicateMux(getVoidLogger());
|
||||
mux.register({
|
||||
predicate: url => url.hostname === 'foo',
|
||||
reader: fooReader,
|
||||
});
|
||||
mux.register({
|
||||
predicate: url => url.hostname === 'bar',
|
||||
reader: barReader,
|
||||
});
|
||||
|
||||
await mux.read('http://foo/1');
|
||||
expect(fooReader.read).toHaveBeenCalledWith('http://foo/1');
|
||||
await mux.readUrl('http://foo/2');
|
||||
expect(fooReader.readUrl).toHaveBeenCalledWith('http://foo/2', undefined);
|
||||
await mux.readTree('http://foo/3');
|
||||
expect(fooReader.readTree).toHaveBeenCalledWith('http://foo/3', undefined);
|
||||
await mux.search('http://foo/4');
|
||||
expect(fooReader.search).toHaveBeenCalledWith('http://foo/4', undefined);
|
||||
|
||||
await mux.read('http://bar/1');
|
||||
expect(barReader.read).toHaveBeenCalledWith('http://bar/1');
|
||||
await mux.readUrl('http://bar/2');
|
||||
expect(barReader.readUrl).toHaveBeenCalledWith('http://bar/2', undefined);
|
||||
await mux.readTree('http://bar/3');
|
||||
expect(barReader.readTree).toHaveBeenCalledWith('http://bar/3', undefined);
|
||||
await mux.search('http://bar/4');
|
||||
expect(barReader.search).toHaveBeenCalledWith('http://bar/4', undefined);
|
||||
});
|
||||
|
||||
it('throws an error if no predicate matches', async () => {
|
||||
const mux = new UrlReaderPredicateMux(getVoidLogger());
|
||||
|
||||
await expect(mux.readUrl('http://foo/1')).rejects.toThrowError(
|
||||
/^Reading from 'http:\/\/foo\/1' is not allowed. You may/,
|
||||
);
|
||||
|
||||
mux.register({
|
||||
predicate: url => url.hostname === 'foo',
|
||||
reader: {
|
||||
read: jest.fn(),
|
||||
readUrl: jest.fn(),
|
||||
readTree: jest.fn(),
|
||||
search: jest.fn(),
|
||||
},
|
||||
});
|
||||
|
||||
await expect(mux.readUrl('http://foo/1')).resolves.toBeUndefined();
|
||||
|
||||
await expect(mux.readUrl('http://bar/1')).rejects.toThrowError(
|
||||
/^Reading from 'http:\/\/bar\/1' is not allowed. You may/,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -29,6 +29,14 @@ import {
|
||||
|
||||
const MIN_WARNING_INTERVAL_MS = 1000 * 60 * 15;
|
||||
|
||||
function notAllowedMessage(url: string) {
|
||||
return (
|
||||
`Reading from '${url}' is not allowed. ` +
|
||||
`You may need to configure an integration for the target host, or add it ` +
|
||||
`to the configured list of allowed hosts at 'backend.reading.allow'`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A UrlReader implementation that selects from a set of UrlReaders
|
||||
* based on a predicate tied to each reader.
|
||||
@@ -52,11 +60,7 @@ export class UrlReaderPredicateMux implements UrlReader {
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotAllowedError(
|
||||
`Reading from '${url}' is not allowed. ` +
|
||||
`You may need to configure an integration for the target host, or add it ` +
|
||||
`to the configured list of allowed hosts at 'backend.reading.allow'`,
|
||||
);
|
||||
throw new NotAllowedError(notAllowedMessage(url));
|
||||
}
|
||||
|
||||
async readUrl(
|
||||
@@ -87,7 +91,7 @@ export class UrlReaderPredicateMux implements UrlReader {
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotAllowedError(`Reading from '${url}' is not allowed`);
|
||||
throw new NotAllowedError(notAllowedMessage(url));
|
||||
}
|
||||
|
||||
async readTree(
|
||||
@@ -102,7 +106,7 @@ export class UrlReaderPredicateMux implements UrlReader {
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotAllowedError(`Reading from '${url}' is not allowed`);
|
||||
throw new NotAllowedError(notAllowedMessage(url));
|
||||
}
|
||||
|
||||
async search(url: string, options?: SearchOptions): Promise<SearchResponse> {
|
||||
@@ -114,7 +118,7 @@ export class UrlReaderPredicateMux implements UrlReader {
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotAllowedError(`Reading from '${url}' is not allowed`);
|
||||
throw new NotAllowedError(notAllowedMessage(url));
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Reference in New Issue
Block a user