Added support for individual user policy mapping in github auth backend. (#2079)

This commit is contained in:
Daniel Somerfield
2016-11-10 13:21:14 -08:00
committed by Jeff Mitchell
parent 2cd3cfd83e
commit c1d2dd5fb9
3 changed files with 44 additions and 10 deletions

View File

@@ -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),
}
}