From ca5198c7b64f76027bf7b7cc4592c62b42fee623 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Mon, 26 Mar 2018 12:56:57 +0100 Subject: Ignore blank role names in getRolesByName call. (#8507) --- api4/role_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'api4/role_test.go') diff --git a/api4/role_test.go b/api4/role_test.go index 3fbf6808d..c5d8e303e 100644 --- a/api4/role_test.go +++ b/api4/role_test.go @@ -129,13 +129,21 @@ func TestGetRolesByNames(t *testing.T) { assert.Contains(t, received, role2) assert.Contains(t, received, role3) - // Check a list of invalid roles. - // TODO: Confirm whether no error for invalid role names is intended. + // Check a list of non-existant roles. received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId()}) CheckNoError(t, resp) + // Empty list should error. _, resp = th.SystemAdminClient.GetRolesByNames([]string{}) CheckBadRequestStatus(t, resp) + + // Invalid role name should error. + received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "!!!!!!"}) + CheckBadRequestStatus(t, resp) + + // Empty/whitespace rolenames should be ignored. + received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "", " "}) + CheckNoError(t, resp) } func TestPatchRole(t *testing.T) { -- cgit v1.2.3-1-g7c22