コード例 #1
0
ファイル: acl_restful.go プロジェクト: rgw5267/libsecurity-go
func (a aclRestful) restGetWhoUsesAResourcePermission(request *restful.Request, response *restful.Response) {
	resourceName := request.PathParameter(resourceNameParam)
	permission := request.PathParameter(permissionParam)
	res := acl.GetWhoUseAPermission(a.st.UsersList, resourceName, permission)
	data := []string{}
	response.WriteHeader(http.StatusOK)
	for name, _ := range res {
		data = append(data, name)
	}
	response.WriteHeader(http.StatusOK)
	response.WriteEntity(data)
}
コード例 #2
0
// Test restGetWhoUsesAResourcePermission
// Add a set of permissions to resource for a given users list and verify that the respobse is as expected
func Test_getWhoUsesAResourcePermission(t *testing.T) {
	initState()
	generateAcl()
	permission := perAll
	baseUrl := fmt.Sprintf(cr.ConvertCommandToRequest(urlCommands[getAllPermissionsOfEntityCommand]), resourceToken, resourceName1, permissionsToken, permission)
	url := fmt.Sprintf("%v/%v", resourcePath, baseUrl)
	data := acl.GetWhoUseAPermission(stRestful.UsersList, resourceName1, permission)
	res := []string{}
	for p, _ := range data {
		res = append(res, p)
	}
	exeCommandCheckRes(t, cr.GET_STR, url, http.StatusOK, "", res)
}