mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-03 20:17:59 +00:00 
			
		
		
		
	Added support for individual user policy mapping in github auth backend. (#2079)
This commit is contained in:
		
				
					committed by
					
						
						Jeff Mitchell
					
				
			
			
				
	
			
			
			
						parent
						
							2cd3cfd83e
						
					
				
				
					commit
					c1d2dd5fb9
				
			@@ -112,15 +112,19 @@ func TestBackend_basic(t *testing.T) {
 | 
			
		||||
			testAccStepConfig(t, false),
 | 
			
		||||
			testAccMap(t, "default", "fakepol"),
 | 
			
		||||
			testAccMap(t, "oWnErs", "fakepol"),
 | 
			
		||||
			testAccLogin(t, []string{"fakepol"}),
 | 
			
		||||
			testAccLogin(t, []string{"default", "fakepol"}),
 | 
			
		||||
			testAccStepConfig(t, true),
 | 
			
		||||
			testAccMap(t, "default", "fakepol"),
 | 
			
		||||
			testAccMap(t, "oWnErs", "fakepol"),
 | 
			
		||||
			testAccLogin(t, []string{"fakepol"}),
 | 
			
		||||
			testAccLogin(t, []string{"default", "fakepol"}),
 | 
			
		||||
			testAccStepConfigWithBaseURL(t),
 | 
			
		||||
			testAccMap(t, "default", "fakepol"),
 | 
			
		||||
			testAccMap(t, "oWnErs", "fakepol"),
 | 
			
		||||
			testAccLogin(t, []string{"fakepol"}),
 | 
			
		||||
			testAccLogin(t, []string{"default", "fakepol"}),
 | 
			
		||||
			testAccMap(t, "default", "fakepol"),
 | 
			
		||||
			testAccStepConfig(t, true),
 | 
			
		||||
			mapUserToPolicy(t, os.Getenv("GITHUB_USER"), "userpolicy"),
 | 
			
		||||
			testAccLogin(t, []string{"default", "fakepol", "userpolicy"}),
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
@@ -174,7 +178,17 @@ func testAccMap(t *testing.T, k string, v string) logicaltest.TestStep {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func testAccLogin(t *testing.T, keys []string) logicaltest.TestStep {
 | 
			
		||||
func mapUserToPolicy(t *testing.T, k string, v string) logicaltest.TestStep {
 | 
			
		||||
	return logicaltest.TestStep{
 | 
			
		||||
		Operation: logical.UpdateOperation,
 | 
			
		||||
		Path:      "map/users/" + k,
 | 
			
		||||
		Data: map[string]interface{}{
 | 
			
		||||
			"value": v,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func testAccLogin(t *testing.T, policies []string) logicaltest.TestStep {
 | 
			
		||||
	return logicaltest.TestStep{
 | 
			
		||||
		Operation: logical.UpdateOperation,
 | 
			
		||||
		Path:      "login",
 | 
			
		||||
@@ -183,6 +197,6 @@ func testAccLogin(t *testing.T, keys []string) logicaltest.TestStep {
 | 
			
		||||
		},
 | 
			
		||||
		Unauthenticated: true,
 | 
			
		||||
 | 
			
		||||
		Check: logicaltest.TestCheckAuth([]string{"default", "fakepol"}),
 | 
			
		||||
		Check: logicaltest.TestCheckAuth(policies),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user