Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: [VAULT-20186] decode uri for all attributes in the table #23695

Merged
merged 3 commits into from
Oct 17, 2023
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
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 @@ -345,7 +345,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 @@ -19,12 +19,16 @@ import { deleteEngineCmd, mountEngineCmd, runCmd, tokenWithPolicyCmd } from 'vau

const searchSelectComponent = create(searchSelect);

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 @@ -480,6 +484,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 = this.backend;
const connection = await newConnection(
backend,
'mongodb-database-plugin',
'{{username}}/{{password}}@oracle-xe:1521/XEPDB1'
);
await navToConnection(backend, connection);
assert
.dom('[data-test-row-value="Connection URL"]')
.hasText('{{username}}/{{password}}@oracle-xe:1521/XEPDB1');
});
Comment on lines +487 to +498
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to verify, if you remove the decode-uri helper from the template this test fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-10-17 at 10 34 33 AM Yup it fails 😊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect thanks for adding this test!


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