From 6e4726ba5c4c1464fe4c6e2f265ed19979ddb346 Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Tue, 7 Nov 2023 17:09:12 -0600 Subject: [PATCH] [FIX] renamed package to `authb` FIX #7 --- account_jstieredlimits.go | 2 +- account_limits.go | 2 +- account_signingkeys.go | 2 +- accounts.go | 2 +- auth.go | 2 +- key.go | 2 +- operator.go | 2 +- operator_signingkeys.go | 2 +- providers/nsc/nsc.go | 36 ++++++++++++------------- scope.go | 2 +- tests/accounts_test.go | 24 ++++++++--------- tests/jetstreamstore_test.go | 4 +-- tests/nscstore_test.go | 4 +-- tests/operator_test.go | 30 ++++++++++----------- tests/users_test.go | 52 ++++++++++++++++++------------------ types.go | 2 +- user.go | 2 +- users.go | 2 +- 18 files changed, 87 insertions(+), 87 deletions(-) diff --git a/account_jstieredlimits.go b/account_jstieredlimits.go index 695f389..5a6126c 100644 --- a/account_jstieredlimits.go +++ b/account_jstieredlimits.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "fmt" diff --git a/account_limits.go b/account_limits.go index ecbfaff..129a2c7 100644 --- a/account_limits.go +++ b/account_limits.go @@ -1,4 +1,4 @@ -package nats_auth +package authb type accountLimits struct { data *AccountData diff --git a/account_signingkeys.go b/account_signingkeys.go index 75af213..f3f967f 100644 --- a/account_signingkeys.go +++ b/account_signingkeys.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/jwt/v2" diff --git a/accounts.go b/accounts.go index 052a0a9..97352d7 100644 --- a/accounts.go +++ b/accounts.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "errors" diff --git a/auth.go b/auth.go index 5d79837..7ac4548 100644 --- a/auth.go +++ b/auth.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "fmt" diff --git a/key.go b/key.go index a7ed4ac..c2e0c46 100644 --- a/key.go +++ b/key.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/nkeys" diff --git a/operator.go b/operator.go index 4674407..d8f55b2 100644 --- a/operator.go +++ b/operator.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/jwt/v2" diff --git a/operator_signingkeys.go b/operator_signingkeys.go index 506da7c..52da417 100644 --- a/operator_signingkeys.go +++ b/operator_signingkeys.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import "github.com/nats-io/nkeys" diff --git a/providers/nsc/nsc.go b/providers/nsc/nsc.go index 516f4f9..6d81b7f 100644 --- a/providers/nsc/nsc.go +++ b/providers/nsc/nsc.go @@ -36,8 +36,8 @@ func (a *NscProvider) MaybeMakeDir(path string) error { return err } -func (a *NscProvider) Load() ([]*nats_auth.OperatorData, error) { - var operators []*nats_auth.OperatorData +func (a *NscProvider) Load() ([]*authb.OperatorData, error) { + var operators []*authb.OperatorData if err := a.MaybeMakeDir(a.storesDir); err != nil { return nil, err } @@ -74,7 +74,7 @@ func (a *NscProvider) loadStore(name string) (store.IStore, error) { return nil, err } -func (a *NscProvider) loadOperator(si store.IStore) (*nats_auth.OperatorData, error) { +func (a *NscProvider) loadOperator(si store.IStore) (*authb.OperatorData, error) { token, err := si.ReadRawOperatorClaim() if err != nil { return nil, err @@ -83,20 +83,20 @@ func (a *NscProvider) loadOperator(si store.IStore) (*nats_auth.OperatorData, er if err != nil { return nil, err } - od := &nats_auth.OperatorData{BaseData: nats_auth.BaseData{EntityName: si.GetName(), Loaded: oc.IssuedAt}, Claim: oc} + od := &authb.OperatorData{BaseData: authb.BaseData{EntityName: si.GetName(), Loaded: oc.IssuedAt}, Claim: oc} ks := store.NewKeyStore(od.EntityName) kp, err := ks.GetKeyPair(oc.Issuer) if err != nil { return nil, err } if kp != nil { - od.Key, _ = nats_auth.KeyFromNkey(kp, nkeys.PrefixByteOperator) + od.Key, _ = authb.KeyFromNkey(kp, nkeys.PrefixByteOperator) } if len(oc.SigningKeys) > 0 { for _, sk := range oc.SigningKeys { skp, _ := ks.GetKeyPair(sk) if skp != nil { - k, _ := nats_auth.KeyFromNkey(skp, nkeys.PrefixByteOperator) + k, _ := authb.KeyFromNkey(skp, nkeys.PrefixByteOperator) if k != nil { od.OperatorSigningKeys = append(od.OperatorSigningKeys, k) } @@ -113,8 +113,8 @@ func (a *NscProvider) loadOperator(si store.IStore) (*nats_auth.OperatorData, er return od, err } -func (a *NscProvider) loadAccounts(si store.IStore, ks store.KeyStore) ([]*nats_auth.AccountData, error) { - var datas []*nats_auth.AccountData +func (a *NscProvider) loadAccounts(si store.IStore, ks store.KeyStore) ([]*authb.AccountData, error) { + var datas []*authb.AccountData accountNames, err := si.ListSubContainers(store.Accounts) if err != nil { return nil, err @@ -129,8 +129,8 @@ func (a *NscProvider) loadAccounts(si store.IStore, ks store.KeyStore) ([]*nats_ return datas, nil } -func (a *NscProvider) loadAccount(si store.IStore, ks store.KeyStore, name string) (*nats_auth.AccountData, error) { - ad := &nats_auth.AccountData{BaseData: nats_auth.BaseData{EntityName: name}} +func (a *NscProvider) loadAccount(si store.IStore, ks store.KeyStore, name string) (*authb.AccountData, error) { + ad := &authb.AccountData{BaseData: authb.BaseData{EntityName: name}} token, err := si.ReadRawAccountClaim(name) if err != nil { return nil, err @@ -143,13 +143,13 @@ func (a *NscProvider) loadAccount(si store.IStore, ks store.KeyStore, name strin ad.Loaded = ad.Claim.IssuedAt k, _ := ks.GetKeyPair(ad.Claim.Subject) if k != nil { - ad.Key, _ = nats_auth.KeyFromNkey(k, nkeys.PrefixByteAccount) + ad.Key, _ = authb.KeyFromNkey(k, nkeys.PrefixByteAccount) } keys := ad.Claim.SigningKeys.Keys() for _, k := range keys { skp, _ := ks.GetKeyPair(k) if skp != nil { - sk, _ := nats_auth.KeyFromNkey(skp, nkeys.PrefixByteOperator) + sk, _ := authb.KeyFromNkey(skp, nkeys.PrefixByteOperator) if sk != nil { ad.AccountSigningKeys = append(ad.AccountSigningKeys, sk) } @@ -168,8 +168,8 @@ func (a *NscProvider) loadAccount(si store.IStore, ks store.KeyStore, name strin return ad, err } -func (a *NscProvider) loadUsers(si store.IStore, ks store.KeyStore, account string) ([]*nats_auth.UserData, error) { - var datas []*nats_auth.UserData +func (a *NscProvider) loadUsers(si store.IStore, ks store.KeyStore, account string) ([]*authb.UserData, error) { + var datas []*authb.UserData names, err := si.ListEntries(store.Accounts, account, store.Users) if err != nil { return nil, err @@ -184,9 +184,9 @@ func (a *NscProvider) loadUsers(si store.IStore, ks store.KeyStore, account stri return datas, nil } -func (a *NscProvider) loadUser(si store.IStore, ks store.KeyStore, account string, name string) (*nats_auth.UserData, error) { +func (a *NscProvider) loadUser(si store.IStore, ks store.KeyStore, account string, name string) (*authb.UserData, error) { var err error - ud := &nats_auth.UserData{BaseData: nats_auth.BaseData{EntityName: name}} + ud := &authb.UserData{BaseData: authb.BaseData{EntityName: name}} token, err := si.ReadRawUserClaim(account, name) if err != nil { return nil, err @@ -201,14 +201,14 @@ func (a *NscProvider) loadUser(si store.IStore, ks store.KeyStore, account strin if err != nil { return nil, err } - ud.Key, err = nats_auth.KeyFromNkey(kp, nkeys.PrefixByteUser) + ud.Key, err = authb.KeyFromNkey(kp, nkeys.PrefixByteUser) if err != nil { return nil, err } return ud, nil } -func (a *NscProvider) Store(operators []*nats_auth.OperatorData) error { +func (a *NscProvider) Store(operators []*authb.OperatorData) error { for _, o := range operators { var err error ks := store.NewKeyStore(o.EntityName) diff --git a/scope.go b/scope.go index 2073f24..1d24abc 100644 --- a/scope.go +++ b/scope.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "errors" diff --git a/tests/accounts_test.go b/tests/accounts_test.go index d8e63f5..a24e43a 100644 --- a/tests/accounts_test.go +++ b/tests/accounts_test.go @@ -2,13 +2,13 @@ package tests import ( "github.com/stretchr/testify/require" - "github.com/synadia-io/jwt-auth-builder.go" + authb "github.com/synadia-io/jwt-auth-builder.go" "time" ) func (suite *ProviderSuite) Test_AccountsCrud() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -50,7 +50,7 @@ func (suite *ProviderSuite) Test_AccountsCrud() { func (suite *ProviderSuite) Test_AccountsBasics() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -58,14 +58,14 @@ func (suite *ProviderSuite) Test_AccountsBasics() { a, err := o.Accounts().Add("A") require.NoError(t, err) - ai := a.(*nats_auth.AccountData) + ai := a.(*authb.AccountData) require.Equal(t, ai.Claim.Subject, a.Subject()) require.Equal(t, o.Subject(), a.Issuer()) } -func setupTestWithOperatorAndAccount(p *ProviderSuite) (nats_auth.Auth, nats_auth.Operator, nats_auth.Account) { +func setupTestWithOperatorAndAccount(p *ProviderSuite) (authb.Auth, authb.Operator, authb.Account) { t := p.T() - auth, err := nats_auth.NewAuth(p.Provider) + auth, err := authb.NewAuth(p.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -230,7 +230,7 @@ func (suite *ProviderSuite) Test_ScopedPermissionsConnectionTimes() { s, err := a.ScopedSigningKeys().AddScope("admin") require.NoError(t, err) times := s.ConnectionTimes() - require.NoError(t, times.Set(nats_auth.TimeRange{Start: "08:00:00", End: "12:00:00"})) + require.NoError(t, times.Set(authb.TimeRange{Start: "08:00:00", End: "12:00:00"})) require.Len(t, times.List(), 1) require.NoError(t, auth.Commit()) @@ -316,7 +316,7 @@ func (suite *ProviderSuite) Test_ScopedPermissionsSubject() { func (suite *ProviderSuite) Test_ScopeRotation() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -354,7 +354,7 @@ func (suite *ProviderSuite) Test_ScopeRotation() { func (suite *ProviderSuite) Test_SigningKeyRotation() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -384,7 +384,7 @@ func (suite *ProviderSuite) Test_SigningKeyRotation() { func (suite *ProviderSuite) Test_AccountLimits() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -424,7 +424,7 @@ func (suite *ProviderSuite) Test_AccountLimits() { require.True(t, a.Limits().DisallowBearerTokens()) } -func (suite *ProviderSuite) testTier(auth nats_auth.Auth, account nats_auth.Account, tier int8) { +func (suite *ProviderSuite) testTier(auth authb.Auth, account authb.Account, tier int8) { t := suite.T() var err error @@ -540,7 +540,7 @@ func (suite *ProviderSuite) testTier(auth nats_auth.Auth, account nats_auth.Acco func (suite *ProviderSuite) Test_AccountJetStreamLimits() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) diff --git a/tests/jetstreamstore_test.go b/tests/jetstreamstore_test.go index e90bfe3..e700e23 100644 --- a/tests/jetstreamstore_test.go +++ b/tests/jetstreamstore_test.go @@ -30,7 +30,7 @@ func (ts *KvStore) KeyExists(k string) bool { return v != nil } -func (ts *KvStore) GetKey(k string) *nats_auth.Key { +func (ts *KvStore) GetKey(k string) *authb.Key { v, err := ts.provider.GetKey(k) require.NoError(ts.t, err) return v @@ -49,7 +49,7 @@ func (ts *KvStore) OperatorExists(name string) bool { } func (ts *KvStore) GetOperator(name string) *jwt.OperatorClaims { - var v *nats_auth.OperatorData + var v *authb.OperatorData operators, err := ts.provider.LoadOperators() require.NoError(ts.t, err) for _, o := range operators { diff --git a/tests/nscstore_test.go b/tests/nscstore_test.go index 5441cb4..a9e5e2c 100644 --- a/tests/nscstore_test.go +++ b/tests/nscstore_test.go @@ -40,11 +40,11 @@ func (ts *NscStore) KeyExists(k string) bool { return err == nil } -func (ts *NscStore) GetKey(k string) *nats_auth.Key { +func (ts *NscStore) GetKey(k string) *authb.Key { fp := filepath.Join(ts.KeysDir(), store.KeysDir, k[:1], k[1:3], fmt.Sprintf("%s%s", k, store.NKeyExtension)) d, err := os.ReadFile(fp) require.NoError(ts.t, err) - key, err := nats_auth.KeyFrom(string(d)) + key, err := authb.KeyFrom(string(d)) require.NoError(ts.t, err) return key } diff --git a/tests/operator_test.go b/tests/operator_test.go index 1d92a2c..ccb8a9b 100644 --- a/tests/operator_test.go +++ b/tests/operator_test.go @@ -4,12 +4,12 @@ import ( "github.com/nats-io/jwt/v2" "github.com/nats-io/nkeys" "github.com/stretchr/testify/require" - "github.com/synadia-io/jwt-auth-builder.go" + authb "github.com/synadia-io/jwt-auth-builder.go" ) func (suite *ProviderSuite) Test_OperatorBasics() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) operators := auth.Operators() @@ -41,7 +41,7 @@ func (suite *ProviderSuite) Test_OperatorBasics() { func (suite *ProviderSuite) Test_OperatorValidation() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -50,14 +50,14 @@ func (suite *ProviderSuite) Test_OperatorValidation() { func (suite *ProviderSuite) Test_OperatorLoads() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) require.NotNil(t, o) require.NoError(t, auth.Commit()) - auth, err = nats_auth.NewAuth(suite.Provider) + auth, err = authb.NewAuth(suite.Provider) require.NoError(t, err) o = auth.Operators().Get("O") require.NoError(t, err) @@ -66,7 +66,7 @@ func (suite *ProviderSuite) Test_OperatorLoads() { func (suite *ProviderSuite) Test_OperatorSigningKeys() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -114,7 +114,7 @@ func (suite *ProviderSuite) Test_OperatorSigningKeys() { func (suite *ProviderSuite) Test_OperatorAccountServerURL() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -128,7 +128,7 @@ func (suite *ProviderSuite) Test_OperatorAccountServerURL() { func (suite *ProviderSuite) Test_OperatorServiceURL() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -142,7 +142,7 @@ func (suite *ProviderSuite) Test_OperatorServiceURL() { func (suite *ProviderSuite) Test_OperatorUsesMainKeyToSignAccount() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -155,7 +155,7 @@ func (suite *ProviderSuite) Test_OperatorUsesMainKeyToSignAccount() { func (suite *ProviderSuite) Test_OperatorUsesSigningKeyToSignAccount() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -173,7 +173,7 @@ func (suite *ProviderSuite) Test_OperatorUsesSigningKeyToSignAccount() { func (suite *ProviderSuite) Test_OperatorRotate() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -196,7 +196,7 @@ func (suite *ProviderSuite) Test_OperatorRotate() { func (suite *ProviderSuite) Test_OperatorSystemAccount() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -214,15 +214,15 @@ func (suite *ProviderSuite) Test_OperatorSystemAccount() { func (suite *ProviderSuite) Test_OperatorImport() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) - kp, err := nats_auth.KeyFor(nkeys.PrefixByteOperator) + kp, err := authb.KeyFor(nkeys.PrefixByteOperator) require.NoError(t, err) oc := jwt.NewOperatorClaims(kp.Public) oc.Name = "O" - skp, err := nats_auth.KeyFor(nkeys.PrefixByteOperator) + skp, err := authb.KeyFor(nkeys.PrefixByteOperator) require.NoError(t, err) oc.SigningKeys.Add(skp.Public) diff --git a/tests/users_test.go b/tests/users_test.go index 953ad10..f6d1241 100644 --- a/tests/users_test.go +++ b/tests/users_test.go @@ -3,13 +3,13 @@ package tests import ( "github.com/nats-io/jwt/v2" "github.com/stretchr/testify/require" - "github.com/synadia-io/jwt-auth-builder.go" + authb "github.com/synadia-io/jwt-auth-builder.go" "time" ) func (suite *ProviderSuite) Test_UserBasics() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -54,7 +54,7 @@ func (suite *ProviderSuite) Test_UserBasics() { func (suite *ProviderSuite) Test_UserWithSigningKey() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -68,14 +68,14 @@ func (suite *ProviderSuite) Test_UserWithSigningKey() { u, err := a.Users().Add("U", k) require.NoError(t, err) require.NotNil(t, u) - ud := u.(*nats_auth.UserData) + ud := u.(*authb.UserData) require.Equal(t, k, ud.Claim.Issuer) require.Equal(t, a.Subject(), ud.Claim.IssuerAccount) } -func setupScopeUser(suite *ProviderSuite) nats_auth.User { +func setupScopeUser(suite *ProviderSuite) authb.User { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -93,7 +93,7 @@ func setupScopeUser(suite *ProviderSuite) nats_auth.User { require.NoError(t, err) require.NotNil(t, u) require.True(t, u.IsScoped()) - ud := u.(*nats_auth.UserData) + ud := u.(*authb.UserData) require.Equal(t, scope.Key(), ud.Claim.Issuer) require.Equal(t, a.Subject(), ud.Claim.IssuerAccount) @@ -107,7 +107,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSetMaxSubscriptions() { require.Equal(t, int64(0), n) err := u.SetMaxSubscriptions(100) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserSetMaxSubscriptions() { @@ -138,7 +138,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSetMaxPayload() { require.Equal(t, int64(0), n) err := u.SetMaxPayload(100) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserSetMaxPayload() { @@ -169,7 +169,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSetMaxData() { require.Equal(t, int64(0), n) err := u.SetMaxData(100) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserSetMaxData() { @@ -200,7 +200,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSetBearerToken() { require.Equal(t, false, n) err := u.SetBearerToken(true) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsSetLocale() { @@ -210,7 +210,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSetLocale() { require.Equal(t, "", n) err := u.SetLocale("") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsPubPermissions() { @@ -221,14 +221,14 @@ func (suite *ProviderSuite) Test_ScopedUserFailsPubPermissions() { err := u.PubPermissions().SetAllow("foo") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) n = u.PubPermissions().Deny() require.Empty(t, n) err = u.PubPermissions().SetDeny("foo") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsSubPermissions() { @@ -239,14 +239,14 @@ func (suite *ProviderSuite) Test_ScopedUserFailsSubPermissions() { err := u.SubPermissions().SetAllow("foo") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) n = u.SubPermissions().Deny() require.Empty(t, n) err = u.SubPermissions().SetDeny("foo") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsRespondPermissions() { @@ -258,11 +258,11 @@ func (suite *ProviderSuite) Test_ScopedUserFailsRespondPermissions() { err := perms.SetExpires(time.Second) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) err = perms.SetMaxMessages(1) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsConnectionTypes() { @@ -273,7 +273,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsConnectionTypes() { err := types.Set("websocket") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsConnectionSources() { @@ -284,7 +284,7 @@ func (suite *ProviderSuite) Test_ScopedUserFailsConnectionSources() { err := types.Set("192.0.2.0/24") require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } func (suite *ProviderSuite) Test_ScopedUserFailsConnectionTimes() { @@ -293,14 +293,14 @@ func (suite *ProviderSuite) Test_ScopedUserFailsConnectionTimes() { times := u.ConnectionTimes() require.Empty(t, times.List()) - err := times.Set(nats_auth.TimeRange{Start: "00:00:00", End: "23:59:01"}) + err := times.Set(authb.TimeRange{Start: "00:00:00", End: "23:59:01"}) require.Error(t, err) - require.Equal(t, nats_auth.ErrUserIsScoped, err) + require.Equal(t, authb.ErrUserIsScoped, err) } -func setupUser(suite *ProviderSuite) (nats_auth.Auth, nats_auth.User) { +func setupUser(suite *ProviderSuite) (authb.Auth, authb.User) { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -316,7 +316,7 @@ func setupUser(suite *ProviderSuite) (nats_auth.Auth, nats_auth.User) { func (suite *ProviderSuite) Test_Creds() { t := suite.T() - auth, err := nats_auth.NewAuth(suite.Provider) + auth, err := authb.NewAuth(suite.Provider) require.NoError(t, err) o, err := auth.Operators().Add("O") require.NoError(t, err) @@ -334,6 +334,6 @@ func (suite *ProviderSuite) Test_Creds() { require.NoError(t, err) require.True(t, uc.ClaimsData.Expires > 0) - ud := u.(*nats_auth.UserData) + ud := u.(*authb.UserData) require.Equal(t, int64(0), ud.Claim.Expires) } diff --git a/types.go b/types.go index d5420c5..af67819 100644 --- a/types.go +++ b/types.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/jwt/v2" diff --git a/user.go b/user.go index c98d571..a5a8575 100644 --- a/user.go +++ b/user.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/jwt/v2" diff --git a/users.go b/users.go index ae72087..8d8a251 100644 --- a/users.go +++ b/users.go @@ -1,4 +1,4 @@ -package nats_auth +package authb import ( "github.com/nats-io/jwt/v2"