Skip to content

Commit

Permalink
Add test cases for ToJAASTag, make the way fetchRelations returns tup…
Browse files Browse the repository at this point in the history
…les clearer
  • Loading branch information
pkulik0 committed Jun 13, 2024
1 parent 73ed66d commit deb676a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cmd/jimmctl/cmd/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ func fetchRelations(client *api.Client, params apiparams.ListRelationshipTuplesR
tuples = append(tuples, response.Tuples...)

if response.ContinuationToken == "" {
response.Tuples = tuples
return response, nil
return &apiparams.ListRelationshipTuplesResponse{Tuples: tuples, Errors: response.Errors}, nil
}
params.ContinuationToken = response.ContinuationToken
}
Expand Down
10 changes: 9 additions & 1 deletion internal/jujuapi/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/canonical/jimm/internal/jujuapi"
"github.com/canonical/jimm/internal/openfga"
ofganames "github.com/canonical/jimm/internal/openfga/names"
"github.com/canonical/jimm/pkg/names"
)

type accessControlSuite struct {
Expand Down Expand Up @@ -792,7 +793,8 @@ func (s *accessControlSuite) TestJAASTag(c *gc.C) {
ctx := context.Background()
db := s.JIMM.Database

user, _, controller, model, applicationOffer, cloud, _, _, closeClient := createTestControllerEnvironment(ctx, c, s)
user, group, controller, model, applicationOffer, cloud, _, _, closeClient := createTestControllerEnvironment(ctx, c, s)
serviceAccountId := petname.Generate(2, "-") + "@serviceaccount"
closeClient()

tests := []struct {
Expand All @@ -802,6 +804,12 @@ func (s *accessControlSuite) TestJAASTag(c *gc.C) {
}{{
tag: ofganames.ConvertTag(user.ResourceTag()),
expectedJAASTag: "user-" + user.Name,
}, {
tag: ofganames.ConvertTag(names.NewServiceAccountTag(serviceAccountId)),
expectedJAASTag: "serviceaccount-" + serviceAccountId,
}, {
tag: ofganames.ConvertTag(group.ResourceTag()),
expectedJAASTag: "group-" + group.Name,
}, {
tag: ofganames.ConvertTag(controller.ResourceTag()),
expectedJAASTag: "controller-" + controller.Name,
Expand Down

0 comments on commit deb676a

Please sign in to comment.