Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/23695.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Decode the connection url for display on the connection details page
```
12 changes: 12 additions & 0 deletions ui/app/helpers/decode-uri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import { helper as buildHelper } from '@ember/component/helper';

export function decodeUri(string) {
return decodeURI(string);
}

export default buildHelper(decodeUri);
2 changes: 1 addition & 1 deletion ui/app/templates/components/database-connection.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
@alwaysRender={{not (is-empty-value (get @model attr.name) hasDefault=defaultDisplay)}}
@defaultShown={{defaultDisplay}}
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{get @model attr.name}}
@value={{if (eq attr.name "connection_url") (decode-uri (get @model attr.name)) (get @model attr.name)}}
/>
{{/if}}
{{/let}}
Expand Down
21 changes: 19 additions & 2 deletions ui/tests/acceptance/secrets/backend/database/secret-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ const mount = async () => {
return path;
};

const newConnection = async (backend, plugin = 'mongodb-database-plugin') => {
const newConnection = async (
backend,
plugin = 'mongodb-database-plugin',
connectionUrl = `mongodb://127.0.0.1:4321/${name}`
) => {
const name = `connection-${Date.now()}`;
await connectionPage.visitCreate({ backend });
await connectionPage.dbPlugin(plugin);
await connectionPage.name(name);
await connectionPage.connectionUrl(`mongodb://127.0.0.1:4321/${name}`);
await connectionPage.connectionUrl(connectionUrl);
await connectionPage.toggleVerify();
await connectionPage.save();
await connectionPage.enable();
Expand Down Expand Up @@ -462,6 +466,19 @@ module('Acceptance | secrets/database/*', function (hooks) {
assert.dom('[data-test-get-credentials]').isEnabled();
});

test('connection_url must be decoded', async function (assert) {
const backend = await mount();
const connection = await newConnection(
backend,
'mongodb-database-plugin',
'{{username}}/{{password}}@oracle-xe:1521/XEPDB1'
);
await connectionPage.visitShow({ backend, id: connection });
assert
.dom('[data-test-row-value="Connection URL"]')
.hasText('{{username}}/{{password}}@oracle-xe:1521/XEPDB1');
});

test('Role create form', async function (assert) {
const backend = await mount();
// Connection needed for role fields
Expand Down