...

Source file src/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_test.go

Documentation: go.mongodb.org/mongo-driver/x/mongo/driver/auth

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  //go:build gssapi
     8  // +build gssapi
     9  
    10  package auth
    11  
    12  import (
    13  	"context"
    14  	"testing"
    15  
    16  	"go.mongodb.org/mongo-driver/mongo/address"
    17  	"go.mongodb.org/mongo-driver/mongo/description"
    18  )
    19  
    20  func TestGSSAPIAuthenticator(t *testing.T) {
    21  	t.Run("PropsError", func(t *testing.T) {
    22  		// Cannot specify both CANONICALIZE_HOST_NAME and SERVICE_HOST
    23  
    24  		authenticator := &GSSAPIAuthenticator{
    25  			Username:    "foo",
    26  			Password:    "bar",
    27  			PasswordSet: true,
    28  			Props: map[string]string{
    29  				"CANONICALIZE_HOST_NAME": "true",
    30  				"SERVICE_HOST":           "localhost",
    31  			},
    32  		}
    33  		desc := description.Server{
    34  			WireVersion: &description.VersionRange{
    35  				Max: 6,
    36  			},
    37  			Addr: address.Address("foo:27017"),
    38  		}
    39  		err := authenticator.Auth(context.Background(), &Config{Description: desc})
    40  		if err == nil {
    41  			t.Fatalf("expected err, got nil")
    42  		}
    43  	})
    44  
    45  }
    46  

View as plain text