Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-1530 GODRIVER-1213 Fix the enterprise auth test runner. #1118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ functions:
- command: shell.exec
type: test
params:
silent: true
working_dir: src/go.mongodb.org/mongo-driver
script: |
# DO NOT ECHO WITH XTRACE
Expand All @@ -350,7 +349,10 @@ functions:
export GOROOT="${GO_DIST}"
export GOCACHE="$GOCACHE"
export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
MONGODB_URI="${MONGODB_URI}" MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
export MONGODB_URI="${MONGODB_URI}"
export MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}"

make -s evg-test-enterprise-auth

run-enterprise-gssapi-auth-tests:
- command: shell.exec
Expand All @@ -377,7 +379,9 @@ functions:
export GOROOT="${GO_DIST}"
export GOCACHE="$GOCACHE"
export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
export MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}"

make -s evg-test-enterprise-auth

run-enterprise-gssapi-service-host-auth-tests:
- command: shell.exec
Expand All @@ -404,7 +408,9 @@ functions:
export GOROOT="${GO_DIST}"
export GOCACHE="$GOCACHE"
export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
export MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}"

make -s evg-test-enterprise-auth

run-atlas-test:
- command: shell.exec
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build:

.PHONY: build-examples
build-examples:
go build $(BUILD_TAGS) ./examples/... ./x/mongo/driver/examples/...
go build $(BUILD_TAGS) ./examples/...

.PHONY: build-no-tags
build-no-tags:
Expand Down Expand Up @@ -128,9 +128,9 @@ evg-test-atlas-data-lake:
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestAtlasDataLake >> spec_test.suite

.PHONY: evg-test-auth
evg-test-auth:
go run -tags gssapi ./x/mongo/driver/examples/count/main.go -uri $(MONGODB_URI)
.PHONY: evg-test-enterprise-auth
evg-test-enterprise-auth:
go run -tags gssapi ./cmd/testentauth/main.go

.PHONY: evg-test-kmip
evg-test-kmip:
Expand Down
51 changes: 51 additions & 0 deletions cmd/testentauth/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (C) MongoDB, Inc. 2022-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package main

import (
"context"
"log"
"os"
"time"

"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
)

func main() {
uri := os.Getenv("MONGODB_URI")
compressor := os.Getenv("MONGO_GO_DRIVER_COMPRESSOR")

client, err := mongo.Connect(
context.Background(),
options.Client().ApplyURI(uri).SetCompressors([]string{compressor}))
if err != nil {
log.Fatalf("Error connecting client: %v", err)
}

// Use the defaultauthdb (i.e. the database name after the "/") specified in the connection
// string to run the count operation.
cs, err := connstring.Parse(uri)
if err != nil {
log.Fatalf("Error parsing connection string: %v", err)
}
if cs.Database == "" {
log.Fatal("Connection string must contain a defaultauthdb.")
}

coll := client.Database(cs.Database).Collection("test")

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

count, err := coll.EstimatedDocumentCount(ctx)
if err != nil {
log.Fatalf("failed executing count command: %v", err)
}
log.Println("Count of test collection:", count)
}
2 changes: 1 addition & 1 deletion x/mongo/driver/connstring/connstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (p *parser) validateAuth() error {
return fmt.Errorf("username required for GSSAPI")
}
for k := range p.AuthMechanismProperties {
if k != "SERVICE_NAME" && k != "CANONICALIZE_HOST_NAME" && k != "SERVICE_REALM" {
if k != "SERVICE_NAME" && k != "CANONICALIZE_HOST_NAME" && k != "SERVICE_REALM" && k != "SERVICE_HOST" {
return fmt.Errorf("invalid auth property for GSSAPI")
}
}
Expand Down
59 changes: 0 additions & 59 deletions x/mongo/driver/examples/count/main.go

This file was deleted.

40 changes: 0 additions & 40 deletions x/mongo/driver/examples/server_monitoring/main.go

This file was deleted.

163 changes: 0 additions & 163 deletions x/mongo/driver/examples/workload/main.go

This file was deleted.