use of com.nexblocks.authguard.config.JacksonConfigContext in project AuthGuard by AuthGuard.
the class SecurePasswordProviderTest method parsesWithPreviousVersions.
@Test
void parsesWithPreviousVersions() {
final ObjectNode configRoot = new ObjectNode(JsonNodeFactory.instance).put("algorithm", "bcrypt").put("validFor", "5d").put("version", 2);
final ObjectNode bcryptConfig = new ObjectNode(JsonNodeFactory.instance);
configRoot.set("bcrypt", bcryptConfig);
final ObjectNode previousPasswordConfig = new ObjectNode(JsonNodeFactory.instance).put("algorithm", "scrypt").put("validFor", "5d").put("version", 1);
final ObjectNode scryptConfig = new ObjectNode(JsonNodeFactory.instance);
previousPasswordConfig.set("scrypt", scryptConfig);
final ArrayNode previousVersions = new ArrayNode(JsonNodeFactory.instance).add(previousPasswordConfig);
configRoot.set("previousVersions", previousVersions);
final ConfigContext configContext = new JacksonConfigContext(configRoot);
final SecurePasswordProvider provider = new SecurePasswordProvider(configContext);
assertThat(provider.getCurrentVersion()).isEqualTo(2);
assertThat(provider.getPreviousVersions().get(1)).isInstanceOf(SCryptPassword.class);
}
use of com.nexblocks.authguard.config.JacksonConfigContext in project AuthGuard by AuthGuard.
the class SecurePasswordProviderTest method parsesWithoutPreviousVersions.
@Test
void parsesWithoutPreviousVersions() {
final ObjectNode configRoot = new ObjectNode(JsonNodeFactory.instance).put("algorithm", "bcrypt").put("validFor", "5d");
final ObjectNode bcryptConfig = new ObjectNode(JsonNodeFactory.instance);
configRoot.set("bcrypt", bcryptConfig);
final ConfigContext configContext = new JacksonConfigContext(configRoot);
final SecurePasswordProvider provider = new SecurePasswordProvider(configContext);
assertThat(provider.getCurrentVersion()).isEqualTo(1);
}
use of com.nexblocks.authguard.config.JacksonConfigContext in project AuthGuard by AuthGuard.
the class SessionProviderTest method sessionsConfig.
private ConfigContext sessionsConfig() {
final ObjectNode configNode = new ObjectNode(JsonNodeFactory.instance);
configNode.put("randomSize", 128).put("lifeTime", "20m");
return new JacksonConfigContext(configNode);
}
use of com.nexblocks.authguard.config.JacksonConfigContext in project AuthGuard by AuthGuard.
the class MessageBusTest method setup.
@BeforeAll
void setup() {
final ObjectNode configNode = new ObjectNode(JsonNodeFactory.instance);
configNode.set("channels", new ArrayNode(JsonNodeFactory.instance).add("accounts").add("auth"));
final ConfigContext configContext = new JacksonConfigContext(configNode);
messageBus = new MessageBus(new RxPublisherFactory(), configContext);
}
use of com.nexblocks.authguard.config.JacksonConfigContext in project AuthGuard by AuthGuard.
the class AutoSubscribersTest method subscribe.
@Test
void subscribe() {
final ObjectNode configRoot = new ObjectNode(JsonNodeFactory.instance);
final ArrayNode allowed = new ArrayNode(JsonNodeFactory.instance).add("com.nexblocks.authguard.emb.AutoSubscribersTest.ToBeSubscribed").add("com.nexblocks.authguard.emb.AutoSubscribersTest.NotToBeSubscribed");
configRoot.set("subscribers", allowed);
final MessageBus messageBus = Mockito.mock(MessageBus.class);
final ToBeSubscribed toBeSubscribed = new ToBeSubscribed();
final NotToBeSubscribed notToBeSubscribed = new NotToBeSubscribed();
final ConfigContext configContext = new JacksonConfigContext(configRoot);
final AutoSubscribers autoSubscribers = new AutoSubscribers(messageBus, ImmutableSet.of(toBeSubscribed, notToBeSubscribed), configContext);
autoSubscribers.subscribe();
Mockito.verify(messageBus, Mockito.times(1)).subscribe("test", toBeSubscribed);
Mockito.verify(messageBus, Mockito.never()).subscribe(Mockito.any(), Mockito.eq(notToBeSubscribed));
}
Aggregations