Fix/add mongo srv support (#3341)
Provide helpful error msg when srv url is provided to mongo plugin Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
This commit is contained in:
parent
75b0986b92
commit
639913703a
|
|
@ -338,6 +338,17 @@ public class MongoPlugin extends BasePlugin {
|
|||
|
||||
}
|
||||
|
||||
if(!CollectionUtils.isEmpty(endpoints)) {
|
||||
boolean usingSrvUrl = endpoints
|
||||
.stream()
|
||||
.anyMatch(endPoint -> endPoint.getHost().contains("mongodb+srv"));
|
||||
|
||||
if (usingSrvUrl) {
|
||||
invalids.add("MongoDb SRV URLs are not yet supported. Please extract the individual fields from " +
|
||||
"the SRV URL into the datasource configuration form.");
|
||||
}
|
||||
}
|
||||
|
||||
DBAuth authentication = (DBAuth) datasourceConfiguration.getAuthentication();
|
||||
if (authentication != null) {
|
||||
DBAuth.Type authType = authentication.getAuthType();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
|
@ -404,4 +405,19 @@ public class MongoPluginTest {
|
|||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorMessageOnSrvUrl() {
|
||||
DatasourceConfiguration dsConfig = createDatasourceConfiguration();
|
||||
dsConfig.getEndpoints().get(0).setHost("mongodb+srv:://url.net");
|
||||
Mono<Set<String>> invalidsMono = Mono.just(pluginExecutor.validateDatasource(dsConfig));
|
||||
|
||||
StepVerifier.create(invalidsMono)
|
||||
.assertNext(invalids -> {
|
||||
assertTrue(invalids
|
||||
.stream()
|
||||
.anyMatch(error -> error.contains("MongoDb SRV URLs are not yet supported")));
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user