use of edu.hawaii.its.api.service.HttpRequestService in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method doGrouperHandshake.
@Test
@WithMockUhUser
public void doGrouperHandshake() {
GroupingsRestController controller = applicationContext.getBean(GroupingsRestController.class);
assertFalse(controller.shouldDoApiHandshake());
try {
controller.doApiHandshake();
} catch (Exception e) {
fail("Should not reach here.");
}
Realm realm = controller.getRealm();
Realm realmMock = mock(Realm.class);
// Swap in mock.
controller.setRealm(realmMock);
assertTrue(mockingDetails(controller.getRealm()).isMock());
given(realmMock.isAnyProfileActive("default", "localTest")).willReturn(false);
try {
controller.doApiHandshake();
fail("Should not reach here.");
} catch (Exception e) {
assertThat(e, instanceOf(ApiServerHandshakeException.class));
}
// Cause in an internal exception.
HttpRequestService httpRequestServiceOriginal = controller.getHttpRequestService();
controller.setHttpRequestService(null);
try {
controller.doApiHandshake();
fail("Should not reach here.");
} catch (Exception e) {
assertThat(e, instanceOf(ApiServerHandshakeException.class));
}
// Put stuff back.
controller.setHttpRequestService(httpRequestServiceOriginal);
controller.setRealm(realm);
assertFalse(mockingDetails(controller.getRealm()).isMock());
}
Aggregations