From 08f5f7fe2d6f7324f123960c13b70fe9388dee9b Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Thu, 16 Nov 2023 14:42:17 +0100 Subject: [PATCH] Ensure the operator token is set during load Signed-off-by: R.I.Pienaar --- providers/nsc/nsc.go | 2 +- tests/operator_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/providers/nsc/nsc.go b/providers/nsc/nsc.go index 6d81b7f..a477486 100644 --- a/providers/nsc/nsc.go +++ b/providers/nsc/nsc.go @@ -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 { diff --git a/tests/operator_test.go b/tests/operator_test.go index ccb8a9b..16d3012 100644 --- a/tests/operator_test.go +++ b/tests/operator_test.go @@ -212,6 +212,25 @@ 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") + + _, err = o.MemResolver() + require.NoError(t, err) +} + func (suite *ProviderSuite) Test_OperatorImport() { t := suite.T() auth, err := authb.NewAuth(suite.Provider)