This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 7045aa6a8 test(metrics): verify optional data source credentials on
the wire (#5172)
7045aa6a8 is described below
commit 7045aa6a80dc1a97b1ebdb3f023ac648365f8380
Author: Loyal-Young <[email protected]>
AuthorDate: Fri Nov 27 11:55:05 2026 +0800
test(metrics): verify optional data source credentials on the wire (#5172)
---
web/src/api/metrics.test.ts | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/web/src/api/metrics.test.ts b/web/src/api/metrics.test.ts
index 64dc33478..c767fdfe2 100644
--- a/web/src/api/metrics.test.ts
+++ b/web/src/api/metrics.test.ts
@@ -118,12 +118,9 @@ describe('metrics API', () => {
mock.onPost('/metrics/query/datasource').reply((config) => {
expect(config.params).toEqual({ key: 'ds-prom-1' });
- expect(JSON.parse(config.data)).toEqual({
+ expect(JSON.parse(config.data)).toStrictEqual({
query: dsQuery.query,
instanceId: 'instance-1',
- username: undefined,
- password: undefined,
- bearerToken: undefined,
});
return [200, { code: 200, data: result }];
});
@@ -131,6 +128,32 @@ describe('metrics API', () => {
await expect(queryByDataSource(dsQuery)).resolves.toEqual(result);
});
+ it('forwards data-source credentials only when supplied for the query',
async () => {
+ const query = { metric: 'up', start: 1, end: 2, step: '1m' };
+ const result = { resultType: 'matrix', series: [], warnings: [] };
+
+ mock.onPost('/metrics/query/datasource').reply((config) => {
+ expect(config.params).toStrictEqual({ key: 'ds-prom-1' });
+ expect(JSON.parse(config.data)).toStrictEqual({
+ query,
+ username: 'operator',
+ password: 'temporary-password',
+ bearerToken: 'temporary-token',
+ });
+ return [200, { code: 200, data: result }];
+ });
+
+ await expect(
+ queryByDataSource({
+ key: 'ds-prom-1',
+ query,
+ username: 'operator',
+ password: 'temporary-password',
+ bearerToken: 'temporary-token',
+ }),
+ ).resolves.toStrictEqual(result);
+ });
+
it('loads version-aware metric profiles', async () => {
const profiles = [
{