Skip to content

Commit

Permalink
Ensure the operator token is set during load
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <rip@devco.net>
  • Loading branch information
ripienaar committed Nov 16, 2023
1 parent df8e419 commit d9c3c0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion providers/nsc/nsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (a *NscProvider) loadOperator(si store.IStore) (*authb.OperatorData, error)
if err != nil {
return nil, err
}
od := &authb.OperatorData{BaseData: authb.BaseData{EntityName: si.GetName(), Loaded: oc.IssuedAt}, Claim: oc}
od := &authb.OperatorData{BaseData: authb.BaseData{EntityName: si.GetName(), Loaded: oc.IssuedAt, Token: string(token)}, Claim: oc}
ks := store.NewKeyStore(od.EntityName)
kp, err := ks.GetKeyPair(oc.Issuer)
if err != nil {
Expand Down
23 changes: 23 additions & 0 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tests

import (
"fmt"

"github.com/nats-io/jwt/v2"
"github.com/nats-io/nkeys"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -212,6 +214,27 @@ func (suite *ProviderSuite) Test_OperatorSystemAccount() {
require.NoError(t, o.Accounts().Delete("SYS"))
}

func (suite *ProviderSuite) Test_MemResolver() {
t := suite.T()
auth, err := authb.NewAuth(suite.Provider)
require.NoError(t, err)

_, err = auth.Operators().Add("O")
require.NoError(t, err)

require.NoError(t, auth.Commit())

auth, err = authb.NewAuth(suite.Provider)
require.NoError(t, err)

o := auth.Operators().Get("O")

out, err := o.MemResolver()
require.NoError(t, err)

require.Contains(t, string(out), fmt.Sprintf("operator: %v", o.))
}

func (suite *ProviderSuite) Test_OperatorImport() {
t := suite.T()
auth, err := authb.NewAuth(suite.Provider)
Expand Down

0 comments on commit d9c3c0a

Please sign in to comment.