drop User Password Auth, only url and dbname
This commit is contained in:
parent
3ec559676d
commit
763b6a0f63
@ -8,9 +8,6 @@ import (
|
||||
|
||||
type Configuration struct {
|
||||
URL string `env:"MONGO_URL,required"`
|
||||
User string `env:"MONGO_USER,required"`
|
||||
Password string `env:"MONGO_PASSWORD,required"`
|
||||
Auth string `env:"MONGO_AUTH,required"`
|
||||
DatabaseName string `env:"MONGO_DB_NAME,required"`
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,7 @@ func Connect(ctx context.Context, deps *ConnectDeps) (*mongo.Database, error) {
|
||||
}
|
||||
|
||||
connectionOptions := options.Client().
|
||||
ApplyURI(deps.Configuration.URL).
|
||||
SetAuth(options.Credential{
|
||||
AuthMechanism: "SCRAM-SHA-1",
|
||||
AuthSource: deps.Configuration.Auth,
|
||||
Username: deps.Configuration.User,
|
||||
Password: deps.Configuration.Password,
|
||||
}).SetMonitor(cmdMonitor)
|
||||
ApplyURI(deps.Configuration.URL).SetMonitor(cmdMonitor)
|
||||
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
timeoutExceeded := time.After(deps.Timeout)
|
||||
|
@ -13,9 +13,6 @@ func TestConnectMongo(t *testing.T) {
|
||||
d, err := Connect(ctx, &ConnectDeps{
|
||||
Configuration: &Configuration{
|
||||
URL: "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0&readPreference=primary&ssl=false",
|
||||
User: "test",
|
||||
Password: "test",
|
||||
Auth: "admin",
|
||||
DatabaseName: "test_replicaset",
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
@ -25,10 +22,7 @@ func TestConnectMongo(t *testing.T) {
|
||||
|
||||
d2, err := Connect(ctx, &ConnectDeps{
|
||||
Configuration: &Configuration{
|
||||
URL: "mongodb://localhost:27020/",
|
||||
User: "test",
|
||||
Password: "test",
|
||||
Auth: "admin",
|
||||
URL: "mongodb://test:test@localhost:27020/",
|
||||
DatabaseName: "test_default",
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
|
Loading…
Reference in New Issue
Block a user