Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

[WIP] PMM-8125 Set the default authentication database #817

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

percona-csalguero
Copy link
Contributor

In the DSN for MongoDB, an empty database will make the connection to fail since the driver is not setting it to the default authentication database.
This is a WIP. Do not merge

PMM-8125 Investigate issue with official mongoDB and no queries in QAN page


  • Tests passed.
  • Feature build pass.
  • (Re)requested review.

In the DSN for MongoDB, an empty database will make the connection to
fail since the driver is not setting it to the default authentication
database.
@@ -168,8 +168,8 @@ func TestAgent(t *testing.T) {
agent.MongoDBOptions.AuthenticationMechanism = "MONGO-X509"
agent.MongoDBOptions.AuthenticationDatabase = "$external"

assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?authMechanism=MONGO-X509&authSource=%24external&connectTimeoutMS=1000&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, time.Second, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?authMechanism=MONGO-X509&authSource=%24external&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, 0, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/admin?authMechanism=MONGO-X509&authSource=%24external&connectTimeoutMS=1000&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, time.Second, "", nil))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [Linters] reported by reviewdog 🐶
line is 321 characters (lll)

assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?authMechanism=MONGO-X509&authSource=%24external&connectTimeoutMS=1000&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, time.Second, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?authMechanism=MONGO-X509&authSource=%24external&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, 0, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/admin?authMechanism=MONGO-X509&authSource=%24external&connectTimeoutMS=1000&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, time.Second, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/admin?authMechanism=MONGO-X509&authSource=%24external&ssl=true&tlsCaFile={{.TextFiles.caFilePlaceholder}}&tlsCertificateKeyFile={{.TextFiles.certificateKeyFilePlaceholder}}", agent.DSN(service, 0, "", nil))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [Linters] reported by reviewdog 🐶
line is 289 characters (lll)

@@ -207,8 +207,8 @@ func TestAgent(t *testing.T) {
t.Run("MongoDBNoDatabase", func(t *testing.T) {
agent.AgentType = models.MongoDBExporterType

assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?connectTimeoutMS=1000&ssl=true&tlsInsecure=true", agent.DSN(service, time.Second, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/?ssl=true&tlsInsecure=true", agent.DSN(service, 0, "", nil))
assert.Equal(t, "mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:12345/admin?connectTimeoutMS=1000&ssl=true&tlsInsecure=true", agent.DSN(service, time.Second, "", nil))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [Linters] reported by reviewdog 🐶
line is 180 characters (lll)

@codecov
Copy link

codecov bot commented Aug 17, 2021

Codecov Report

Merging #817 (2b2c187) into PMM-2.0 (828d1dc) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           PMM-2.0     #817   +/-   ##
========================================
  Coverage    49.35%   49.35%           
========================================
  Files          168      168           
  Lines        18745    18745           
========================================
  Hits          9252     9252           
  Misses        8482     8482           
  Partials      1011     1011           
Flag Coverage Δ
all 48.95% <100.00%> (ø)
cover 48.84% <100.00%> (ø)
crosscover 49.35% <100.00%> (ø)
update 13.12% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
models/agent_model.go 91.27% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 828d1dc...2b2c187. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant