2022-05-09 12:45:10 -07:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2022-04-27 08:13:46 -07:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2020-06-22 06:56:27 -07:00
|
|
|
package roles_test
|
|
|
|
|
|
2020-08-08 17:46:41 -04:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/api"
|
|
|
|
|
"github.com/hashicorp/boundary/api/groups"
|
|
|
|
|
"github.com/hashicorp/boundary/api/roles"
|
|
|
|
|
"github.com/hashicorp/boundary/api/users"
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
2022-05-09 12:45:10 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/daemon/controller"
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/iam"
|
2020-08-08 17:46:41 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
2020-07-02 10:26:31 -07:00
|
|
|
|
2020-07-10 11:21:11 -07:00
|
|
|
func TestCustom(t *testing.T) {
|
2020-08-08 17:46:41 -04:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
2020-09-08 13:27:51 -07:00
|
|
|
tc := controller.NewTestController(t, nil)
|
2020-07-10 11:21:11 -07:00
|
|
|
defer tc.Shutdown()
|
|
|
|
|
|
|
|
|
|
client := tc.Client()
|
2020-09-08 13:27:51 -07:00
|
|
|
token := tc.Token()
|
|
|
|
|
client.SetToken(token.Token)
|
|
|
|
|
org, proj := iam.TestScopes(t, tc.IamRepo(), iam.WithUserId(token.UserId))
|
2020-07-10 11:21:11 -07:00
|
|
|
|
|
|
|
|
cases := []struct {
|
2020-09-08 13:27:51 -07:00
|
|
|
name string
|
|
|
|
|
scopeId string
|
2020-07-10 11:21:11 -07:00
|
|
|
}{
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "org",
|
|
|
|
|
scopeId: org.GetPublicId(),
|
2020-07-10 11:21:11 -07:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "proj",
|
|
|
|
|
scopeId: proj.GetPublicId(),
|
2020-07-10 11:21:11 -07:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
user, err := users.NewClient(client).Create(tc.Context(), org.GetPublicId())
|
2020-08-08 17:46:41 -04:00
|
|
|
require.NoError(err)
|
|
|
|
|
|
2020-07-14 14:32:47 -07:00
|
|
|
hasPrincipal := func(role *roles.Role, principalId string) bool {
|
|
|
|
|
var foundInPrincipals bool
|
|
|
|
|
var foundInPrincipalIds bool
|
|
|
|
|
for _, v := range role.Principals {
|
|
|
|
|
if v.Id == principalId {
|
|
|
|
|
foundInPrincipals = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for _, v := range role.PrincipalIds {
|
|
|
|
|
if v == principalId {
|
|
|
|
|
foundInPrincipalIds = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return foundInPrincipals && foundInPrincipalIds
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 17:46:41 -04:00
|
|
|
for _, tt := range cases {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2020-09-24 14:34:58 -07:00
|
|
|
g, err := groups.NewClient(client).Create(tc.Context(), tt.scopeId)
|
2020-07-10 11:21:11 -07:00
|
|
|
require.NoError(err)
|
|
|
|
|
require.NotNil(g)
|
|
|
|
|
|
2020-09-08 13:27:51 -07:00
|
|
|
rc := roles.NewClient(client)
|
2024-01-23 14:33:09 -05:00
|
|
|
var version uint32 = 2
|
2020-08-08 17:46:41 -04:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
r, err := rc.Create(tc.Context(), tt.scopeId, roles.WithName("foo"))
|
2020-07-10 11:21:11 -07:00
|
|
|
require.NoError(err)
|
|
|
|
|
require.NotNil(r)
|
2020-09-15 01:08:21 -04:00
|
|
|
require.EqualValues(r.Item.Version, version)
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 11:21:11 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
updatedRole, err := rc.AddPrincipals(tc.Context(), r.Item.Id, r.Item.Version, []string{g.Item.Id})
|
2020-07-10 11:21:11 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
|
|
|
|
assert.True(hasPrincipal(updatedRole.Item, g.Item.Id))
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 11:21:11 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
updatedRole, err = rc.SetPrincipals(tc.Context(), updatedRole.Item.Id, updatedRole.Item.Version, []string{user.Item.Id})
|
2020-07-10 11:21:11 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
|
|
|
|
assert.True(hasPrincipal(updatedRole.Item, user.Item.Id))
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 11:21:11 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
updatedRole, err = rc.RemovePrincipals(tc.Context(), updatedRole.Item.Id, updatedRole.Item.Version, []string{user.Item.Id})
|
2020-07-10 11:21:11 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
|
|
|
|
assert.Empty(updatedRole.Item.Principals)
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 17:42:47 -07:00
|
|
|
|
2024-01-17 23:54:49 -08:00
|
|
|
updatedRole, err = rc.AddGrants(tc.Context(), updatedRole.Item.Id, updatedRole.Item.Version, []string{"ids=*;type=*;actions=read"})
|
2020-07-10 17:42:47 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
2024-01-17 23:54:49 -08:00
|
|
|
assert.Contains(updatedRole.Item.GrantStrings, "ids=*;type=*;actions=read")
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 17:42:47 -07:00
|
|
|
|
2024-01-17 23:54:49 -08:00
|
|
|
updatedRole, err = rc.SetGrants(tc.Context(), updatedRole.Item.Id, updatedRole.Item.Version, []string{"ids=*;type=*;actions=*"})
|
2020-07-10 17:42:47 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
2024-01-17 23:54:49 -08:00
|
|
|
assert.Contains(updatedRole.Item.GrantStrings, "ids=*;type=*;actions=*")
|
2020-08-08 17:46:41 -04:00
|
|
|
version++
|
2020-07-10 17:42:47 -07:00
|
|
|
|
2024-01-17 23:54:49 -08:00
|
|
|
updatedRole, err = rc.RemoveGrants(tc.Context(), updatedRole.Item.Id, updatedRole.Item.Version, []string{"ids=*;type=*;actions=*"})
|
2020-07-10 17:42:47 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.EqualValues(updatedRole.Item.Version, version)
|
|
|
|
|
assert.Empty(updatedRole.Item.Grants)
|
2020-07-10 11:21:11 -07:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 13:27:51 -07:00
|
|
|
func TestList(t *testing.T) {
|
2020-08-08 17:46:41 -04:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
2020-09-08 13:27:51 -07:00
|
|
|
tc := controller.NewTestController(t, nil)
|
2020-07-02 10:26:31 -07:00
|
|
|
defer tc.Shutdown()
|
|
|
|
|
|
|
|
|
|
client := tc.Client()
|
2020-09-08 13:27:51 -07:00
|
|
|
token := tc.Token()
|
|
|
|
|
client.SetToken(token.Token)
|
|
|
|
|
org, proj := iam.TestScopes(t, tc.IamRepo(), iam.WithUserId(token.UserId))
|
2020-07-02 10:26:31 -07:00
|
|
|
|
|
|
|
|
cases := []struct {
|
2020-09-08 13:27:51 -07:00
|
|
|
name string
|
|
|
|
|
scopeId string
|
2020-07-02 10:26:31 -07:00
|
|
|
}{
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "org",
|
|
|
|
|
scopeId: org.GetPublicId(),
|
2020-07-02 10:26:31 -07:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "proj",
|
|
|
|
|
scopeId: proj.GetPublicId(),
|
2020-07-02 10:26:31 -07:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 17:46:41 -04:00
|
|
|
for _, tt := range cases {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2020-09-08 13:27:51 -07:00
|
|
|
var expected []*roles.Role
|
|
|
|
|
|
|
|
|
|
roleClient := roles.NewClient(client)
|
2020-09-24 14:34:58 -07:00
|
|
|
p1, err := roleClient.List(tc.Context(), tt.scopeId)
|
2020-07-14 14:32:47 -07:00
|
|
|
require.NoError(err)
|
2020-10-13 13:56:21 -04:00
|
|
|
var numBuiltIn int
|
|
|
|
|
switch tt.name {
|
|
|
|
|
case "org":
|
|
|
|
|
numBuiltIn = 2
|
|
|
|
|
case "proj":
|
2021-02-11 13:14:18 -05:00
|
|
|
numBuiltIn = 2
|
2020-10-13 13:56:21 -04:00
|
|
|
}
|
|
|
|
|
require.Len(p1.Items, numBuiltIn)
|
|
|
|
|
expected = append(expected, p1.Items[0:numBuiltIn]...)
|
2020-07-02 10:26:31 -07:00
|
|
|
|
2020-10-13 13:56:21 -04:00
|
|
|
for i := numBuiltIn; i < 10+numBuiltIn; i++ {
|
2020-08-08 17:46:41 -04:00
|
|
|
expected = append(expected, &roles.Role{Name: fmt.Sprint(i)})
|
2020-07-02 10:26:31 -07:00
|
|
|
}
|
|
|
|
|
|
2020-10-13 13:56:21 -04:00
|
|
|
rcr, err := roleClient.Create(tc.Context(), tt.scopeId, roles.WithName(expected[numBuiltIn].Name))
|
2020-07-14 14:32:47 -07:00
|
|
|
require.NoError(err)
|
2020-10-13 13:56:21 -04:00
|
|
|
expected[numBuiltIn] = rcr.Item
|
2020-07-02 10:26:31 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
p2, err := roleClient.List(tc.Context(), tt.scopeId)
|
2020-09-15 01:08:21 -04:00
|
|
|
require.NoError(err)
|
2020-10-13 13:56:21 -04:00
|
|
|
assert.ElementsMatch(comparableSlice(expected[0:numBuiltIn+1]), comparableSlice(p2.Items))
|
2020-07-02 10:26:31 -07:00
|
|
|
|
2020-10-13 13:56:21 -04:00
|
|
|
for i := numBuiltIn + 1; i < 10+numBuiltIn; i++ {
|
2020-09-24 14:34:58 -07:00
|
|
|
rcr, err = roleClient.Create(tc.Context(), tt.scopeId, roles.WithName(expected[i].Name))
|
2020-07-02 10:26:31 -07:00
|
|
|
assert.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
expected[i] = rcr.Item
|
2020-07-02 10:26:31 -07:00
|
|
|
}
|
2020-09-24 14:34:58 -07:00
|
|
|
p3, err := roleClient.List(tc.Context(), tt.scopeId)
|
2020-07-14 14:32:47 -07:00
|
|
|
require.NoError(err)
|
2020-09-15 01:08:21 -04:00
|
|
|
assert.ElementsMatch(comparableSlice(expected), comparableSlice(p3.Items))
|
2021-02-22 14:37:14 -07:00
|
|
|
|
|
|
|
|
filterItem := p3.Items[3]
|
|
|
|
|
p3, err = roleClient.List(tc.Context(), tt.scopeId,
|
|
|
|
|
roles.WithFilter(fmt.Sprintf(`"/item/id"==%q`, filterItem.Id)))
|
|
|
|
|
require.NoError(err)
|
|
|
|
|
assert.Len(p3.Items, 1)
|
|
|
|
|
assert.Equal(filterItem.Id, p3.Items[0].Id)
|
2020-07-02 10:26:31 -07:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func comparableSlice(in []*roles.Role) []roles.Role {
|
|
|
|
|
var filtered []roles.Role
|
|
|
|
|
for _, i := range in {
|
|
|
|
|
p := roles.Role{
|
|
|
|
|
Id: i.Id,
|
|
|
|
|
Name: i.Name,
|
|
|
|
|
Description: i.Description,
|
|
|
|
|
CreatedTime: i.CreatedTime,
|
|
|
|
|
UpdatedTime: i.UpdatedTime,
|
|
|
|
|
}
|
|
|
|
|
filtered = append(filtered, p)
|
|
|
|
|
}
|
|
|
|
|
return filtered
|
2020-06-30 10:25:58 -07:00
|
|
|
}
|
|
|
|
|
|
2020-09-08 13:27:51 -07:00
|
|
|
func TestCrud(t *testing.T) {
|
2020-08-08 17:46:41 -04:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
2020-09-08 13:27:51 -07:00
|
|
|
tc := controller.NewTestController(t, nil)
|
2020-06-22 06:56:27 -07:00
|
|
|
defer tc.Shutdown()
|
|
|
|
|
|
|
|
|
|
client := tc.Client()
|
2020-09-08 13:27:51 -07:00
|
|
|
token := tc.Token()
|
|
|
|
|
client.SetToken(token.Token)
|
|
|
|
|
org, proj := iam.TestScopes(t, tc.IamRepo(), iam.WithUserId(token.UserId))
|
2020-06-30 10:25:58 -07:00
|
|
|
|
2020-08-08 17:46:41 -04:00
|
|
|
cases := []struct {
|
2020-09-08 13:27:51 -07:00
|
|
|
name string
|
|
|
|
|
scopeId string
|
2020-08-08 17:46:41 -04:00
|
|
|
}{
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "org",
|
|
|
|
|
scopeId: org.GetPublicId(),
|
2020-08-08 17:46:41 -04:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "proj",
|
|
|
|
|
scopeId: proj.GetPublicId(),
|
2020-08-08 17:46:41 -04:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
checkRole := func(step string, g *roles.Role, err error, wantedName string, wantedVersion uint32) {
|
2020-06-22 06:56:27 -07:00
|
|
|
assert.NoError(err, step)
|
|
|
|
|
assert.NotNil(g, "returned no resource", step)
|
|
|
|
|
gotName := ""
|
2020-08-08 17:46:41 -04:00
|
|
|
if g.Name != "" {
|
|
|
|
|
gotName = g.Name
|
2020-06-22 06:56:27 -07:00
|
|
|
}
|
|
|
|
|
assert.Equal(wantedName, gotName, step)
|
2020-08-08 17:46:41 -04:00
|
|
|
assert.EqualValues(wantedVersion, g.Version)
|
2020-06-30 10:25:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range cases {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2020-09-08 13:27:51 -07:00
|
|
|
roleClient := roles.NewClient(client)
|
2020-09-24 14:34:58 -07:00
|
|
|
g, err := roleClient.Create(tc.Context(), tt.scopeId, roles.WithName("foo"))
|
2024-01-23 14:33:09 -05:00
|
|
|
checkRole("create", g.Item, err, "foo", 2)
|
2020-06-22 06:56:27 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
g, err = roleClient.Read(tc.Context(), g.Item.Id)
|
2024-01-23 14:33:09 -05:00
|
|
|
checkRole("read", g.Item, err, "foo", 2)
|
2020-06-22 06:56:27 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
g, err = roleClient.Update(tc.Context(), g.Item.Id, g.Item.Version, roles.WithName("bar"))
|
2024-01-23 14:33:09 -05:00
|
|
|
checkRole("update", g.Item, err, "bar", 3)
|
2020-06-22 06:56:27 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
g, err = roleClient.Update(tc.Context(), g.Item.Id, g.Item.Version, roles.DefaultName())
|
2024-01-23 14:33:09 -05:00
|
|
|
checkRole("update", g.Item, err, "", 4)
|
2020-06-22 06:56:27 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
_, err = roleClient.Delete(tc.Context(), g.Item.Id)
|
2020-07-14 14:32:47 -07:00
|
|
|
require.NoError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
})
|
|
|
|
|
}
|
2020-06-22 06:56:27 -07:00
|
|
|
}
|
|
|
|
|
|
2020-09-08 13:27:51 -07:00
|
|
|
func TestErrors(t *testing.T) {
|
|
|
|
|
tc := controller.NewTestController(t, nil)
|
2020-06-22 06:56:27 -07:00
|
|
|
defer tc.Shutdown()
|
|
|
|
|
|
|
|
|
|
client := tc.Client()
|
2020-09-08 13:27:51 -07:00
|
|
|
token := tc.Token()
|
|
|
|
|
client.SetToken(token.Token)
|
|
|
|
|
org, proj := iam.TestScopes(t, tc.IamRepo(), iam.WithUserId(token.UserId))
|
2020-06-30 10:25:58 -07:00
|
|
|
|
|
|
|
|
cases := []struct {
|
2020-09-08 13:27:51 -07:00
|
|
|
name string
|
|
|
|
|
scopeId string
|
2020-06-30 10:25:58 -07:00
|
|
|
}{
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "org",
|
|
|
|
|
scopeId: org.GetPublicId(),
|
2020-06-30 10:25:58 -07:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-08 13:27:51 -07:00
|
|
|
name: "proj",
|
|
|
|
|
scopeId: proj.GetPublicId(),
|
2020-06-30 10:25:58 -07:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range cases {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2020-09-24 14:34:58 -07:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
2020-09-08 13:27:51 -07:00
|
|
|
roleClient := roles.NewClient(client)
|
2020-09-24 14:34:58 -07:00
|
|
|
u, err := roleClient.Create(tc.Context(), tt.scopeId, roles.WithName("first"))
|
2020-07-14 14:32:47 -07:00
|
|
|
require.NoError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
assert.NotNil(u)
|
|
|
|
|
|
2022-04-27 08:13:46 -07:00
|
|
|
// A malformed id is processed as the id and not a different path to the api.
|
|
|
|
|
_, err = roleClient.Read(tc.Context(), fmt.Sprintf("%s/../", u.Item.Id))
|
|
|
|
|
require.Error(err)
|
|
|
|
|
apiErr := api.AsServerError(err)
|
|
|
|
|
require.NotNil(apiErr)
|
|
|
|
|
assert.EqualValues(http.StatusBadRequest, apiErr.Response().StatusCode())
|
|
|
|
|
require.Len(apiErr.Details.RequestFields, 1)
|
|
|
|
|
assert.Equal(apiErr.Details.RequestFields[0].Name, "id")
|
|
|
|
|
|
2020-09-21 12:09:30 -07:00
|
|
|
// Updating the wrong version should fail.
|
2020-09-24 14:34:58 -07:00
|
|
|
_, err = roleClient.Update(tc.Context(), u.Item.Id, 73, roles.WithName("anything"))
|
|
|
|
|
require.Error(err)
|
2022-04-27 08:13:46 -07:00
|
|
|
apiErr = api.AsServerError(err)
|
2020-09-21 12:09:30 -07:00
|
|
|
assert.NotNil(apiErr)
|
2021-02-25 12:43:17 -05:00
|
|
|
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
|
2020-09-21 12:09:30 -07:00
|
|
|
|
2020-06-30 10:25:58 -07:00
|
|
|
// Create another resource with the same name.
|
2020-09-24 14:34:58 -07:00
|
|
|
_, err = roleClient.Create(tc.Context(), tt.scopeId, roles.WithName("first"))
|
|
|
|
|
require.Error(err)
|
|
|
|
|
apiErr = api.AsServerError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
assert.NotNil(apiErr)
|
|
|
|
|
|
2023-03-10 15:06:39 -05:00
|
|
|
_, err = roleClient.Read(tc.Context(), globals.RolePrefix+"_doesntexis")
|
2020-09-24 14:34:58 -07:00
|
|
|
require.Error(err)
|
|
|
|
|
apiErr = api.AsServerError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
assert.NotNil(apiErr)
|
2021-02-25 12:43:17 -05:00
|
|
|
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
|
2020-06-30 10:25:58 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
_, err = roleClient.Read(tc.Context(), "invalid id")
|
|
|
|
|
require.Error(err)
|
|
|
|
|
apiErr = api.AsServerError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
assert.NotNil(apiErr)
|
2021-02-25 12:43:17 -05:00
|
|
|
assert.EqualValues(http.StatusBadRequest, apiErr.Response().StatusCode())
|
2020-06-30 10:25:58 -07:00
|
|
|
|
2020-09-24 14:34:58 -07:00
|
|
|
_, err = roleClient.Update(tc.Context(), u.Item.Id, u.Item.Version)
|
|
|
|
|
require.Error(err)
|
|
|
|
|
apiErr = api.AsServerError(err)
|
2020-06-30 10:25:58 -07:00
|
|
|
assert.NotNil(apiErr)
|
2021-02-25 12:43:17 -05:00
|
|
|
assert.EqualValues(http.StatusBadRequest, apiErr.Response().StatusCode())
|
2020-06-30 10:25:58 -07:00
|
|
|
})
|
|
|
|
|
}
|
2020-06-22 06:56:27 -07:00
|
|
|
}
|