Keep Mongo operations online across Vault credential rotation

This commit is contained in:
Stephan D committed 2026-09-12 22:19:36 +02:00
1 parent 80d6917aa7
commit 23f7b78c3b
30 files changed
+1290 -202

No files matched your search

@@ -2,6 +2,10 @@ package accountserviceimp
import (
"context"
"net/url"
"testing"
"time"
"git.sendico.io/tech/sxchnge/product/auth/config"
customermodel "git.sendico.io/tech/sxchnge/product/customers/model"
sessionmodel "git.sendico.io/tech/sxchnge/product/sessions/model"
@@ -15,9 +19,6 @@ import (
"github.com/testcontainers/testcontainers-go/modules/mongodb"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
"net/url"
"testing"
"time"
)
func customer(login string) *customermodel.Account {
@@ -86,7 +87,10 @@ func TestCustomerLifecycleWithoutTenancy(t *testing.T) {
deps, err := edgemongo.ResolveDependencies(factory)
require.NoError(t, err)
collections, err := deps.Database.ListCollectionNames(ctx, bson.D{})
raw, rawContext, release, err := deps.Database.Acquire(ctx)
require.NoError(t, err)
defer release()
collections, err := raw.ListCollectionNames(rawContext, bson.D{})
require.NoError(t, err)
for _, forbidden := range []string{"organizations", "roles", "policies", "policy_assignments", "invitations", "accounts"} {
require.NotContains(t, collections, forbidden)
@@ -116,7 +120,7 @@ func TestCustomerLifecycleWithoutTenancy(t *testing.T) {
require.ErrorIs(t, err, outerFailure)
_, err = svc.accountDB.GetByEmail(ctx, "outer@example.test")
require.ErrorIs(t, err, merrors.ErrNoData)
count, err := deps.Database.Collection(config.VerificationTokensCollection).CountDocuments(ctx, bson.D{})
count, err := raw.Collection(config.VerificationTokensCollection).CountDocuments(rawContext, bson.D{})
require.NoError(t, err)
require.EqualValues(t, 2, count)
}
+4 -4
View File
@@ -1,14 +1,14 @@
package accountdb
import (
customermodel "git.sendico.io/tech/sxchnge/product/customers/model"
"strings"
customermodel "git.sendico.io/tech/sxchnge/product/customers/model"
ri "git.sendico.io/tech/sxchnge/shared/database/repository/index"
"git.sendico.io/tech/sxchnge/shared/database/source"
"git.sendico.io/tech/sxchnge/shared/database/template"
"git.sendico.io/tech/sxchnge/shared/logging"
"git.sendico.io/tech/sxchnge/shared/service"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.uber.org/zap"
)
@@ -16,11 +16,11 @@ type AccountDB struct {
template.DBImp[*customermodel.Account]
}
func Create(logger mlogger.Logger, db *mongo.Database) (*AccountDB, error) {
func Create(logger mlogger.Logger, db source.Source) (*AccountDB, error) {
return CreateWithCollection(logger, db, mservice.Accounts)
}
func CreateWithCollection(logger mlogger.Logger, db *mongo.Database, collection string) (*AccountDB, error) {
func CreateWithCollection(logger mlogger.Logger, db source.Source, collection string) (*AccountDB, error) {
if normalized := strings.TrimSpace(collection); normalized != "" {
collection = normalized
} else {