Skip to content

Commit

Permalink
PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jan 17, 2024
1 parent 9b0641a commit 4f4d9e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/jujuapi/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (r *controllerRoot) Login(ctx context.Context, req jujuparams.LoginRequest)
return jujuparams.LoginResult{}, errors.E(op, err)
}

r.SetUser(u)
r.mu.Lock()
r.user = u
r.mu.Unlock()

var facades []jujuparams.FacadeVersions
for name, f := range facadeInit {
Expand Down
7 changes: 7 additions & 0 deletions internal/jujuapi/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/canonical/jimm/internal/db"
"github.com/canonical/jimm/internal/jimm"
"github.com/canonical/jimm/internal/openfga"
ofganames "github.com/canonical/jimm/internal/openfga/names"
jujuparams "github.com/juju/juju/rpc/params"
)
Expand Down Expand Up @@ -51,3 +52,9 @@ func ToJAASTag(db db.Database, tag *ofganames.Tag) (string, error) {
func NewControllerRoot(j JIMM, p Params) *controllerRoot {
return newControllerRoot(j, p)
}

var SetUser = func(r *controllerRoot, u *openfga.User) {
r.mu.Lock()
r.user = u
r.mu.Unlock()
}
2 changes: 1 addition & 1 deletion internal/jujuapi/service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestUpdateServiceAccountCredentials(t *testing.T) {
u.SetTag(names.NewUserTag(test.username))
user := openfga.NewUser(&u, ofgaClient)
cr := jujuapi.NewControllerRoot(jimm, jujuapi.Params{})
cr.SetUser(user)
jujuapi.SetUser(cr, user)

if len(test.addTuples) > 0 {
ofgaClient.AddRelation(context.Background(), test.addTuples...)
Expand Down

0 comments on commit 4f4d9e8

Please sign in to comment.