本文整理汇总了Java中org.springframework.webflow.test.MockRequestContext类的典型用法代码示例。如果您正苦于以下问题:Java MockRequestContext类的具体用法?Java MockRequestContext怎么用?Java MockRequestContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockRequestContext类属于org.springframework.webflow.test包,在下文中一共展示了MockRequestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureHostnameAndIpShouldDoSpnego
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureHostnameAndIpShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action =
new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");
action.setIpsToCheckPattern("74\\..+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("74.125.136.102");
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());
}
示例2: checkUnautorizedProtocol
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void checkUnautorizedProtocol() throws Exception {
final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, "IndirectBasicAuthClient");
final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);
final MockRequestContext mockRequestContext = new MockRequestContext();
mockRequestContext.setExternalContext(servletExternalContext);
final IndirectBasicAuthClient basicAuthClient = new IndirectBasicAuthClient();
final Clients clients = new Clients(MY_LOGIN_URL, basicAuthClient);
final ClientAction action = new ClientAction();
action.setCentralAuthenticationService(mock(CentralAuthenticationService.class));
action.setClients(clients);
try {
action.execute(mockRequestContext);
fail("Should fail as the HTTP protocol is not authorized");
} catch (final TechnicalException e) {
assertEquals("Only CAS, OAuth, OpenID and SAML protocols are supported: " + basicAuthClient, e.getMessage());
}
}
示例3: ensureLdapAttributeShouldDoSpnego
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureLdapAttributeShouldDoSpnego() {
final LdapSpnegoKnownClientSystemsFilterAction action =
new LdapSpnegoKnownClientSystemsFilterAction(this.connectionFactory,
this.searchRequest, "mail");
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.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:17,代码来源:LdapSpnegoKnownClientSystemsFilterActionTests.java
示例4: verifyIpMismatchWhenCheckingHostnameForSpnego
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void verifyIpMismatchWhenCheckingHostnameForSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action =
new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");
action.setIpsToCheckPattern("14\\..+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("74.125.136.102");
final ServletExternalContext extCtx = new ServletExternalContext(
new MockServletContext(), req,
new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().no(this).getId());
}
示例5: ensureRemoteIpShouldNotBeChecked
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureRemoteIpShouldNotBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action =
new BaseSpnegoKnownClientSystemsFilterAction("^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());
}
示例6: testRenewWithServiceAndDifferentCredentials
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void testRenewWithServiceAndDifferentCredentials() throws Exception {
final String ticketGrantingTicket = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("ticketGrantingTicketId", ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", "test");
request.addParameter("username", "test2");
request.addParameter("password", "test2");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
// this.action.bind(context);
// assertEquals("success", this.action.submit(context).getId());
}
示例7: verifySuccessfulAuthenticationWithServiceAndWarn
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithServiceAndWarn() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
request.addParameter("warn", "true");
request.addParameter("service", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, response));
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:AuthenticationViaFormActionTests.java
示例8: verifyFailedAuthenticationWithNoService
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void verifyFailedAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
final UsernamePasswordCredential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
request.addParameter("username", c.getUsername());
request.addParameter("password", c.getPassword());
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("authenticationFailure", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:AuthenticationViaFormActionTests.java
示例9: verifyRenewWithServiceAndBadCredentials
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndBadCredentials() throws Exception {
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = TestUtils.getService("test");
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", service.getId());
final Credential c2 = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c2);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c2, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("authenticationFailure", this.action.submit(context, c2, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:AuthenticationViaFormActionTests.java
示例10: onSetUp
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Before
public void onSetUp() throws Exception {
this.ticketGrantingTicketCookieGenerator = new CookieRetrievingCookieGenerator();
ticketGrantingTicketCookieGenerator.setCookieName("TGT");
this.action = new SendTicketGrantingTicketAction();
this.action.setCentralAuthenticationService(getCentralAuthenticationService());
this.action.setTicketGrantingTicketCookieGenerator(ticketGrantingTicketCookieGenerator);
this.action.setServicesManager(getServicesManager());
this.action.setCreateSsoSessionCookieOnRenewAuthentications(true);
this.action.afterPropertiesSet();
this.context = new MockRequestContext();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:SendTicketGrantingTicketActionTests.java
示例11: verifyRenewWithServiceAndBadCredentials
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndBadCredentials() throws Exception {
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = TestUtils.getService("test");
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", service.getId());
final Credential c2 = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c2);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c2, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("error", this.action.submit(context, c2, messageContext).getId());
}
示例12: ensureRemoteIpShouldBeChecked
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureRemoteIpShouldBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action =
new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("192.158.5.781");
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());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:AllSpnegoKnownClientSystemsFilterActionTest.java
示例13: ensureRemoteIpShouldNotBeChecked
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureRemoteIpShouldNotBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action =
new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+");
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());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:AllSpnegoKnownClientSystemsFilterActionTest.java
示例14: testRenewWithServiceAndBadCredentials
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void testRenewWithServiceAndBadCredentials() throws Exception {
final String ticketGrantingTicket = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("ticketGrantingTicketId", ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
context.getRequestScope().put("credentials",
TestUtils.getCredentialsWithDifferentUsernameAndPassword());
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(TestUtils
.getCredentialsWithDifferentUsernameAndPassword(),
"credentials"));
// this.action.bind(context);
// assertEquals("error", this.action.submit(context).getId());
}
示例15: ensureHostnameShouldDoSpnego
import org.springframework.webflow.test.MockRequestContext; //导入依赖的package包/类
@Test
public void ensureHostnameShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action =
new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("74.125.136.102");
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());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:AllSpnegoKnownClientSystemsFilterActionTest.java