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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations