use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class OAuth20RegisteredServiceUIActionTests method verifyOAuthActionWithMDUI.
@Test
public void verifyOAuthActionWithMDUI() throws Exception {
final OAuthRegisteredService svc = new OAuthRegisteredService();
svc.setClientId("id");
svc.setName("oauth");
svc.setDescription("description");
svc.setClientSecret("secret");
svc.setInformationUrl("info");
svc.setPrivacyUrl("privacy");
svc.setServiceId("https://oauth\\.example\\.org.*");
svc.setLogo("logo");
servicesManager.save(svc);
final MockRequestContext ctx = new MockRequestContext();
WebUtils.putService(ctx, RegisteredServiceTestUtils.getService("https://www.example.org?client_id=id&client_secret=secret&redirect_uri=https://oauth.example.org"));
final Event event = oauth20RegisteredServiceUIAction.execute(ctx);
assertEquals("success", event.getId());
final DefaultRegisteredServiceUserInterfaceInfo mdui = WebUtils.getServiceUserInterfaceMetadata(ctx, DefaultRegisteredServiceUserInterfaceInfo.class);
assertNotNull(mdui);
assertEquals(mdui.getDisplayName(), svc.getName());
assertEquals(mdui.getInformationURL(), svc.getInformationUrl());
assertEquals(mdui.getDescription(), svc.getDescription());
assertEquals(mdui.getPrivacyStatementURL(), svc.getPrivacyUrl());
assertEquals(mdui.getLogoUrl(), svc.getLogo());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class OAuth20RegisteredServiceUIActionTests method verifyOAuthActionWithoutMDUI.
@Test
public void verifyOAuthActionWithoutMDUI() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
WebUtils.putService(ctx, RegisteredServiceTestUtils.getService());
final Event event = oauth20RegisteredServiceUIAction.execute(ctx);
assertEquals("success", event.getId());
final Serializable mdui = WebUtils.getServiceUserInterfaceMetadata(ctx, Serializable.class);
assertNull(mdui);
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class BaseLdapSpnegoKnownClientSystemsFilterActionTests method ensureLdapAttributeShouldDoSpnego.
@Test
public void ensureLdapAttributeShouldDoSpnego() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("localhost");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.execute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class SpnegoKnownClientSystemsFilterActionTests method ensureHostnameAndIpShouldDoSpnego.
@Test
public void ensureHostnameAndIpShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("74\\..+"), "", 0, "\\w+\\.\\w+\\.\\w+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr(ALTERNATE_REMOTE_IP);
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class SpnegoKnownClientSystemsFilterActionTests method ensureRemoteIpShouldNotBeChecked.
@Test
public void ensureRemoteIpShouldNotBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action = new BaseSpnegoKnownClientSystemsFilterAction(RegexUtils.createPattern("^192\\.158\\..+"), "", 0);
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("193.158.5.781");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertNotEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
Aggregations