From df40a4820e9f0c6564f338f4c51cefbe9dfd3667 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 13 Aug 2018 14:09:20 +0200 Subject: [PATCH] DATAMONGO-2057 - Skip MongoDbUtils integration tests when running against MongoDB 4.0. MongoDB 4.0 digests passwords by default which does not work with the SCRAM-SHA-256 authentication method so we skip those tests when running against MongoDB 4.0. --- .../core/MongoDbUtilsIntegrationTests.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoDbUtilsIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoDbUtilsIntegrationTests.java index f292fd842..00149af5d 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoDbUtilsIntegrationTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoDbUtilsIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,11 +25,13 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; +import com.mongodb.CommandResult; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.dao.DataAccessException; import org.springframework.data.authentication.UserCredentials; +import org.springframework.data.util.Version; import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean; import com.mongodb.DB; @@ -39,10 +41,11 @@ import com.mongodb.MongoException; /** * Integration tests for {@link MongoDbUtils}. - * + * * @author Oliver Gierke * @author Thomas Darimont * @author Christoph Strobl + * @author Mark Paluch */ public class MongoDbUtilsIntegrationTests { @@ -54,6 +57,7 @@ public class MongoDbUtilsIntegrationTests { static MongoTemplate template; static ThreadPoolExecutorFactoryBean factory; static ExecutorService service; + static Version mongoVersion; Exception exception; @@ -71,7 +75,15 @@ public class MongoDbUtilsIntegrationTests { service = factory.getObject(); + CommandResult result = template.executeCommand("{ buildInfo: 1 }"); + mongoVersion = Version.parse(result.get("version").toString()); + assumeFalse(isMongo3Driver()); + assumeFalse(isMongo4Server(mongoVersion)); + } + + private static boolean isMongo4Server(Version mongoVersion) { + return mongoVersion.isGreaterThanOrEqualTo(Version.parse("4.0.0")); } @AfterClass