Search in sources :

Example 21 with Settings

use of jakarta.nosql.Settings in project jnosql-diana-driver by eclipse.

the class MongoAuthenticationTest method shouldReturnOneAuthenticationWithSCRAMSHA256.

@Test
public void shouldReturnOneAuthenticationWithSCRAMSHA256() {
    Settings settings = Settings.builder().put(AUTHENTICATION_SOURCE.get(), "database").put(PASSWORD.get(), "password").put(USER.get(), "user").put(AUTHENTICATION_MECHANISM.get(), "SCRAM-SHA-256").build();
    MongoCredential credential = MongoAuthentication.of(settings).get();
    assertEquals("database", credential.getSource());
    assertTrue(Arrays.equals("password".toCharArray(), credential.getPassword()));
    assertEquals("user", credential.getUserName());
    assertEquals(SCRAM_SHA_256.getMechanismName(), credential.getMechanism());
}
Also used : MongoCredential(com.mongodb.MongoCredential) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 22 with Settings

use of jakarta.nosql.Settings in project jnosql-diana-driver by eclipse.

the class MongoAuthenticationTest method shouldReturnOneAuthenticationWithSCRAMSHA1.

@Test
public void shouldReturnOneAuthenticationWithSCRAMSHA1() {
    Settings settings = Settings.builder().put(AUTHENTICATION_SOURCE.get(), "database").put(PASSWORD.get(), "password").put(USER.get(), "user").put(AUTHENTICATION_MECHANISM.get(), "SCRAM-SHA-1").build();
    MongoCredential credential = MongoAuthentication.of(settings).get();
    assertEquals("database", credential.getSource());
    assertTrue(Arrays.equals("password".toCharArray(), credential.getPassword()));
    assertEquals("user", credential.getUserName());
    assertEquals(SCRAM_SHA_1.getMechanismName(), credential.getMechanism());
}
Also used : MongoCredential(com.mongodb.MongoCredential) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 23 with Settings

use of jakarta.nosql.Settings in project jnosql-diana-driver by eclipse.

the class MongoAuthenticationTest method shouldReturnOneAuthenticationWithMongoX509.

@Test
public void shouldReturnOneAuthenticationWithMongoX509() {
    Settings settings = Settings.builder().put(AUTHENTICATION_SOURCE.get(), "database").put(PASSWORD.get(), "password").put(USER.get(), "user").put(AUTHENTICATION_MECHANISM.get(), "MONGODB-X509").build();
    MongoCredential credential = MongoAuthentication.of(settings).get();
    assertEquals("$external", credential.getSource());
    assertEquals("user", credential.getUserName());
    assertEquals(AuthenticationMechanism.MONGODB_X509.getMechanismName(), credential.getMechanism());
}
Also used : MongoCredential(com.mongodb.MongoCredential) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 24 with Settings

use of jakarta.nosql.Settings in project jnosql-diana-driver by eclipse.

the class MongoAuthenticationTest method shouldReturnErrorWhenTheNumberParameterIsInvalid.

@Test
public void shouldReturnErrorWhenTheNumberParameterIsInvalid() {
    Settings settings = Settings.builder().put(USER.get(), "value").build();
    assertThrows(CommunicationException.class, () -> MongoAuthentication.of(settings));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 25 with Settings

use of jakarta.nosql.Settings in project jnosql-diana-driver by eclipse.

the class MongoAuthenticationTest method shouldReturnOneAuthentication.

@Test
public void shouldReturnOneAuthentication() {
    Settings settings = Settings.builder().put(AUTHENTICATION_SOURCE.get(), "database").put(PASSWORD.get(), "password").put(USER.get(), "user").build();
    MongoCredential credential = MongoAuthentication.of(settings).get();
    assertEquals("database", credential.getSource());
    assertTrue(Arrays.equals("password".toCharArray(), credential.getPassword()));
    assertEquals("user", credential.getUserName());
    assertNull(credential.getMechanism());
}
Also used : MongoCredential(com.mongodb.MongoCredential) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Aggregations

Settings (jakarta.nosql.Settings)42 Test (org.junit.jupiter.api.Test)34 MongoCredential (com.mongodb.MongoCredential)6 Config (org.eclipse.microprofile.config.Config)5 Map (java.util.Map)4 ConfigurationException (org.eclipse.jnosql.mapping.configuration.ConfigurationException)4 SettingsConverter (org.eclipse.jnosql.mapping.configuration.SettingsConverter)4 Reflections (org.eclipse.jnosql.mapping.reflection.Reflections)4 SettingsBuilder (jakarta.nosql.Settings.SettingsBuilder)3 ColumnFamilyManagerFactory (jakarta.nosql.column.ColumnFamilyManagerFactory)3 DocumentConfiguration (jakarta.nosql.document.DocumentConfiguration)2 AbstractMap (java.util.AbstractMap)2 ArrayList (java.util.ArrayList)2 Collections.singletonMap (java.util.Collections.singletonMap)2 ConnectionString (com.mongodb.ConnectionString)1 MongoClientSettings (com.mongodb.MongoClientSettings)1 ServerAddress (com.mongodb.ServerAddress)1 MongoClient (com.mongodb.client.MongoClient)1 MongoClients (com.mongodb.client.MongoClients)1 Configurations (jakarta.nosql.Configurations)1