mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	Fixes redirects to KV engine when secret is a directory (#24281)
* fix * changelog * Update 24281.txt * add test coverage * dont make assumptions about list
This commit is contained in:
		
							
								
								
									
										3
									
								
								changelog/24281.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/24281.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | ```release-note:bug | ||||||
|  | ui: Correctly handle directory redirects from pre 1.15.0 Kv v2 list view urls. | ||||||
|  | ``` | ||||||
| @@ -140,7 +140,7 @@ export default class DashboardQuickActionsCard extends Component { | |||||||
|   @action |   @action | ||||||
|   navigateToPage() { |   navigateToPage() { | ||||||
|     let route = this.searchSelectParams.route; |     let route = this.searchSelectParams.route; | ||||||
|     // If search-select falls back to stringInput, paramVlue is a string not object |     // If search-select falls back to stringInput, paramValue is a string not object | ||||||
|     let param = this.paramValue.id || this.paramValue; |     let param = this.paramValue.id || this.paramValue; | ||||||
|  |  | ||||||
|     // kv has a special use case where if the paramValue ends in a '/' you should |     // kv has a special use case where if the paramValue ends in a '/' you should | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import { allEngines, isAddonEngine } from 'vault/helpers/mountable-secret-engine | |||||||
| import { inject as service } from '@ember/service'; | import { inject as service } from '@ember/service'; | ||||||
| import { normalizePath } from 'vault/utils/path-encoding-helpers'; | import { normalizePath } from 'vault/utils/path-encoding-helpers'; | ||||||
| import { assert } from '@ember/debug'; | import { assert } from '@ember/debug'; | ||||||
|  | import { pathIsDirectory } from 'kv/utils/kv-breadcrumbs'; | ||||||
|  |  | ||||||
| const SUPPORTED_BACKENDS = supportedSecretBackends(); | const SUPPORTED_BACKENDS = supportedSecretBackends(); | ||||||
|  |  | ||||||
| @@ -77,6 +78,9 @@ export default Route.extend({ | |||||||
|       return this.router.replaceWith('vault.cluster.secrets.backend.list', secret + '/'); |       return this.router.replaceWith('vault.cluster.secrets.backend.list', secret + '/'); | ||||||
|     } |     } | ||||||
|     if (isAddonEngine(type, secretEngine.version)) { |     if (isAddonEngine(type, secretEngine.version)) { | ||||||
|  |       if (engineRoute === 'kv.list' && pathIsDirectory(secret)) { | ||||||
|  |         return this.router.transitionTo('vault.cluster.secrets.backend.kv.list-directory', backend, secret); | ||||||
|  |       } | ||||||
|       return this.router.transitionTo(`vault.cluster.secrets.backend.${engineRoute}`, backend); |       return this.router.transitionTo(`vault.cluster.secrets.backend.${engineRoute}`, backend); | ||||||
|     } |     } | ||||||
|     const modelType = this.getModelType(backend, tab); |     const modelType = this.getModelType(backend, tab); | ||||||
|   | |||||||
| @@ -207,6 +207,13 @@ module('Acceptance | kv-v2 workflow | navigation', function (hooks) { | |||||||
|       await click(PAGE.breadcrumbAtIdx(1)); |       await click(PAGE.breadcrumbAtIdx(1)); | ||||||
|       assert.ok(currentURL().startsWith(`/vault/secrets/${backend}/kv/list`), 'links back to list root'); |       assert.ok(currentURL().startsWith(`/vault/secrets/${backend}/kv/list`), 'links back to list root'); | ||||||
|     }); |     }); | ||||||
|  |     test('is redirects to nested secret using old non-engine url (a)', async function (assert) { | ||||||
|  |       // Reported bug, backported fix https://github.com/hashicorp/vault/pull/24281 | ||||||
|  |       assert.expect(1); | ||||||
|  |       const backend = this.backend; | ||||||
|  |       await visit(`/vault/secrets/${backend}/list/app/`); | ||||||
|  |       assert.strictEqual(currentURL(), `/vault/secrets/${backend}/kv/list/app/`); | ||||||
|  |     }); | ||||||
|     test('versioned secret nav, tabs, breadcrumbs (a)', async function (assert) { |     test('versioned secret nav, tabs, breadcrumbs (a)', async function (assert) { | ||||||
|       assert.expect(45); |       assert.expect(45); | ||||||
|       const backend = this.backend; |       const backend = this.backend; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Angel Garbarino
					Angel Garbarino