mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	backport of commit c73eacbaf6 (#23173)
				
					
				
			Co-authored-by: akshya96 <87045294+akshya96@users.noreply.github.com>
This commit is contained in:
		 hc-github-team-secure-vault-core
					hc-github-team-secure-vault-core
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							1e4f08b75e
						
					
				
				
					commit
					2b81921e7b
				
			
							
								
								
									
										3
									
								
								changelog/23155.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/23155.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| ```release-note:bug | ||||
| core: Fixes list password policy to include those with names containing / characters. | ||||
| ``` | ||||
| @@ -3000,11 +3000,13 @@ const ( | ||||
|  | ||||
| // handlePoliciesPasswordList returns the list of password policies | ||||
| func (*SystemBackend) handlePoliciesPasswordList(ctx context.Context, req *logical.Request, data *framework.FieldData) (resp *logical.Response, err error) { | ||||
| 	keys, err := req.Storage.List(ctx, "password_policy/") | ||||
| 	keys, err := logical.CollectKeysWithPrefix(ctx, req.Storage, "password_policy/") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	for i := range keys { | ||||
| 		keys[i] = strings.TrimPrefix(keys[i], "password_policy/") | ||||
| 	} | ||||
| 	return logical.ListResponse(keys), nil | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -4291,6 +4291,66 @@ func TestHandlePoliciesPasswordList(t *testing.T) { | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"policy with /": { | ||||
| 			storage: makeStorage(t, | ||||
| 				&logical.StorageEntry{ | ||||
| 					Key: getPasswordPolicyKey("testpolicy/testpolicy1"), | ||||
| 					Value: toJson(t, | ||||
| 						passwordPolicyConfig{ | ||||
| 							HCLPolicy: "length = 18\n" + | ||||
| 								"rule \"charset\" {\n" + | ||||
| 								"	charset=\"ABCDEFGHIJ\"\n" + | ||||
| 								"}", | ||||
| 						}), | ||||
| 				}, | ||||
| 			), | ||||
|  | ||||
| 			expectedResp: &logical.Response{ | ||||
| 				Data: map[string]interface{}{ | ||||
| 					"keys": []string{"testpolicy/testpolicy1"}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"list path/to/policy": { | ||||
| 			storage: makeStorage(t, | ||||
| 				&logical.StorageEntry{ | ||||
| 					Key: getPasswordPolicyKey("path/to/policy"), | ||||
| 					Value: toJson(t, | ||||
| 						passwordPolicyConfig{ | ||||
| 							HCLPolicy: "length = 18\n" + | ||||
| 								"rule \"charset\" {\n" + | ||||
| 								"	charset=\"ABCDEFGHIJ\"\n" + | ||||
| 								"}", | ||||
| 						}), | ||||
| 				}, | ||||
| 			), | ||||
|  | ||||
| 			expectedResp: &logical.Response{ | ||||
| 				Data: map[string]interface{}{ | ||||
| 					"keys": []string{"path/to/policy"}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"policy ending with /": { | ||||
| 			storage: makeStorage(t, | ||||
| 				&logical.StorageEntry{ | ||||
| 					Key: getPasswordPolicyKey("path/to/policy/"), | ||||
| 					Value: toJson(t, | ||||
| 						passwordPolicyConfig{ | ||||
| 							HCLPolicy: "length = 18\n" + | ||||
| 								"rule \"charset\" {\n" + | ||||
| 								"	charset=\"ABCDEFGHIJ\"\n" + | ||||
| 								"}", | ||||
| 						}), | ||||
| 				}, | ||||
| 			), | ||||
|  | ||||
| 			expectedResp: &logical.Response{ | ||||
| 				Data: map[string]interface{}{ | ||||
| 					"keys": []string{"path/to/policy/"}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"storage failure": { | ||||
| 			storage: new(logical.InmemStorage).FailList(true), | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user