• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TestUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jasig.cas.TestUtils的典型用法代码示例。如果您正苦于以下问题:Java TestUtils类的具体用法?Java TestUtils怎么用?Java TestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestUtils类属于org.jasig.cas包,在下文中一共展示了TestUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testValidServiceTicketWithValidPgtNoProxyHandling

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void testValidServiceTicketWithValidPgtNoProxyHandling() throws Exception {
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final String tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    final String sId = getCentralAuthenticationService()
            .grantServiceTicket(tId, TestUtils.getService());

    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService().getId());
    request.addParameter("ticket", sId);
    request.addParameter("pgtUrl", "https://www.github.com");

    assertEquals(ServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:ServiceValidateControllerTests.java


示例2: verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase() throws Exception {
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    
    final String origSvc = "http://www.jasig.org?param=hello+world";
    final ServiceTicket sId = getCentralAuthenticationService()
            .grantServiceTicket(tId.getId(), TestUtils.getService(origSvc));

    final String reqSvc = "http://WWW.JASIG.ORG?PARAM=hello%20world";
    
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService(reqSvc).getId());
    request.addParameter("ticket", sId.getId());
    
    assertEquals(ServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:AbstractServiceValidateControllerTests.java


示例3: verifyAuthenticationSuccessfulWithAPasswordEncoder

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyAuthenticationSuccessfulWithAPasswordEncoder() throws Exception {
    final QueryAndEncodeDatabaseAuthenticationHandler q =
            new QueryAndEncodeDatabaseAuthenticationHandler(this.dataSource, buildSql(),
                    ALG_NAME);
    q.setNumberOfIterationsFieldName("numIterations");
    q.setStaticSalt(STATIC_SALT);
    q.setPasswordEncoder(new PasswordEncoder() {
        @Override
        public String encode(final String password) {
            return password.concat("1");
        }
    });

    q.setPrincipalNameTransformer(new PrefixSuffixPrincipalNameTransformer("user", null));
    final HandlerResult r = q.authenticateUsernamePasswordInternal(
            TestUtils.getCredentialsWithDifferentUsernameAndPassword("1", "user"));

    assertNotNull(r);
    assertEquals(r.getPrincipal().getId(), "user1");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:QueryAndEncodeDatabaseAuthenticationHandlerTests.java


示例4: setUp

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    final List<RegisteredService> list = new ArrayList<>();

    final RegisteredServiceImpl regSvc = new RegisteredServiceImpl();
    regSvc.setServiceId(TestUtils.getService().getId());
    regSvc.setName("Test Service");
    regSvc.setAttributeReleasePolicy(new ReturnAllAttributeReleasePolicy());

    list.add(regSvc);
    final InMemoryServiceRegistryDaoImpl dao = new InMemoryServiceRegistryDaoImpl();
    dao.setRegisteredServices(list);
    final ServicesManager servicesManager = new DefaultServicesManagerImpl(dao);
    this.response = new Saml10SuccessResponseView();
    this.response.setIssuer("testIssuer");
    this.response.setIssueLength(1000);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:Saml10SuccessResponseViewTests.java


示例5: verifyRenewWithServiceAndSameCredentials

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
    final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(c);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockRequestContext context = new MockRequestContext();

    WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
    WebUtils.putLoginTicket(context, "LOGIN");
    request.addParameter("lt", "LOGIN");

    request.addParameter("renew", "true");
    request.addParameter("service", "test");
    request.addParameter("username", "test");
    request.addParameter("password", "test");

    context.setExternalContext(new ServletExternalContext(
        new MockServletContext(), request, new MockHttpServletResponse()));
    context.getFlowScope().put("service", TestUtils.getService());

    final MessageContext messageContext = mock(MessageContext.class);
    assertEquals("warn", this.action.submit(context, c, messageContext).getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:AuthenticationViaFormActionTests.java


示例6: testWebApplicationServices

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void testWebApplicationServices() {
    final MockService testService = new MockService("test");
    TicketGrantingTicket t = new TicketGrantingTicketImpl("test", null,
        TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
    t.grantServiceTicket(this.uniqueTicketIdGenerator
        .getNewTicketId(ServiceTicket.PREFIX), testService,
        new NeverExpiresExpirationPolicy(), false);
    Map<String, Service> services = t.getServices();
    assertEquals(1, services.size());
    String ticketId = services.keySet().iterator().next();
    assertEquals(testService, services.get(ticketId));
    t.removeAllServices();
    services = t.getServices();
    assertEquals(0, services.size());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:17,代码来源:TicketGrantingTicketImplTests.java


示例7: testTicketGrantingTicketGrantedTwice

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void testTicketGrantingTicketGrantedTwice() {
    Authentication a = TestUtils.getAuthentication();
    TicketGrantingTicket t = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    ServiceTicket s = t.grantServiceTicket(this.uniqueTicketIdGenerator.getNewTicketId(ServiceTicket.PREFIX),
            TestUtils.getService(), new MultiTimeUseOrTimeoutExpirationPolicy(1, 5000), false);
    s.grantTicketGrantingTicket(this.uniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), a,
            new NeverExpiresExpirationPolicy());

    try {
        s.grantTicketGrantingTicket(this.uniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), a,
                new NeverExpiresExpirationPolicy());
        fail("Exception expected.");
    } catch (final Exception e) {
        return;
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:19,代码来源:ServiceTicketImplTests.java


示例8: testTgtIsExpiredByHardTimeOut

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void testTgtIsExpiredByHardTimeOut() throws InterruptedException {
     // keep tgt alive via sliding window until within SLIDING_TIME / 2 of the HARD_TIMEOUT
     while (System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()
             < (HARD_TIMEOUT - SLIDING_TIMEOUT / 2)) {
         ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
         Thread.sleep(SLIDING_TIMEOUT - TIMEOUT_BUFFER);
         assertFalse(this.ticketGrantingTicket.isExpired());
     }

     // final sliding window extension past the HARD_TIMEOUT
     ticketGrantingTicket.grantServiceTicket("test", TestUtils.getService(), expirationPolicy, false);
     Thread.sleep(SLIDING_TIMEOUT / 2 + TIMEOUT_BUFFER);
     assertTrue(ticketGrantingTicket.isExpired());

}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:17,代码来源:TicketGrantingTicketExpirationPolicyTests.java


示例9: testDelegateTicketGrantingTicketWithInvalidCredentials

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void testDelegateTicketGrantingTicketWithInvalidCredentials() throws Exception {
    final String ticketGrantingTicket = this.remoteCentralAuthenticationService
        .createTicketGrantingTicket(TestUtils
            .getCredentialsWithSameUsernameAndPassword());
    final String serviceTicket = this.remoteCentralAuthenticationService
        .grantServiceTicket(ticketGrantingTicket, TestUtils.getService());
    try {
        this.remoteCentralAuthenticationService
            .delegateTicketGrantingTicket(serviceTicket, TestUtils
                .getCredentialsWithDifferentUsernameAndPassword("", ""));
        fail("IllegalArgumentException expected.");
    } catch (final IllegalArgumentException e) {
        return;
    }

}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:RemoteCentralAuthenticationServiceTests.java


示例10: verifyAttributePopulationWithPasswordWithDifferentCredentialsType

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyAttributePopulationWithPasswordWithDifferentCredentialsType() {
    final Authentication auth = TestUtils.getAuthentication();
    final Map<String, String> map = new HashMap<>();
    final CacheCredentialsMetaDataPopulator populator = new CacheCredentialsMetaDataPopulator(map);

    final Credential c = new Credential() {
        @Override
        public String getId() {
            return "something";
        }
    };

    if (populator.supports(c)) {
        populator.populateAttributes(DefaultAuthenticationBuilder.newInstance(auth), c);
    }

    assertEquals(map.size(), 0);

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:CacheCredentialsMetaDataPopulatorTests.java


示例11: verifyUpdateOfRegistry

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyUpdateOfRegistry() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);
    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket("test");

    final ServiceTicket s = returned.grantServiceTicket("test2", TestUtils.getService(),
            new NeverExpiresExpirationPolicy(), true);

    this.ticketRegistry.addTicket(s);
    final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
    assertNotNull(s2.grantTicketGrantingTicket("ff", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy()));

    assertTrue(s2.isValidFor(TestUtils.getService()));
    assertTrue(this.wasTicketUpdated);

    returned.markTicketExpired();
    assertTrue(t.isExpired());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:DistributedTicketRegistryTests.java


示例12: verifyValidServiceTicketWithValidPgtNoProxyHandling

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithValidPgtNoProxyHandling() throws Exception {
    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    final ServiceTicket sId = getCentralAuthenticationService()
            .grantServiceTicket(tId.getId(), TestUtils.getService());

    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService().getId());
    request.addParameter("ticket", sId.getId());
    request.addParameter("pgtUrl", "https://www.github.com");

    assertEquals(ServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:AbstractServiceValidateControllerTests.java


示例13: verifyGetServiceThemeDoesNotExist

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");

    this.servicesManager.save(r);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", TestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader("User-Agent", "Mozilla");
    assertEquals("test", this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceThemeResolverTests.java


示例14: verifyAddTicketToCache

import org.jasig.cas.TestUtils; //导入依赖的package包/类
/**
 * Method to add a TicketGrantingTicket to the ticket cache. This should add
 * the ticket and return. Failure upon any exception.
 */
@Test
public void verifyAddTicketToCache() {
    try {
        this.ticketRegistry.addTicket(new TicketGrantingTicketImpl("TEST", TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy()));
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:EhCacheTicketRegistryTests.java


示例15: verifySaveAndFind

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifySaveAndFind()  {
    final InMemoryServiceRegistryDaoImpl reg = new InMemoryServiceRegistryDaoImpl();
    final RegisteredService svc = TestUtils.getRegisteredService("service");
    assertEquals(reg.save(svc), svc);
    assertEquals(reg.findServiceById(svc.getId()), svc);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:InMemoryServiceRegistryDaoImplTests.java


示例16: verifyEquals

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyEquals() {
    assertNotEquals(TestUtils.getCredentialsWithDifferentUsernameAndPassword(), null);
    assertFalse(TestUtils.getCredentialsWithDifferentUsernameAndPassword().equals(
            TestUtils.getCredentialsWithSameUsernameAndPassword()));
    assertTrue(TestUtils.getCredentialsWithDifferentUsernameAndPassword().equals(
            TestUtils.getCredentialsWithDifferentUsernameAndPassword()));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:UsernamePasswordCredentialTests.java


示例17: newTGT

import org.jasig.cas.TestUtils; //导入依赖的package包/类
static TicketGrantingTicket newTGT() {
    final Principal principal = new DefaultPrincipalFactory().createPrincipal(
            "bob", Collections.singletonMap("displayName", (Object) "Bob"));
    return new TicketGrantingTicketImpl(
            ID_GENERATOR.getNewTicketId("TGT"),
            TestUtils.getAuthentication(principal),
            EXP_POLICY_TGT);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:JpaTicketRegistryTests.java


示例18: verifyAuthenticationFailsToFindUser

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test(expected = AccountNotFoundException.class)
public void verifyAuthenticationFailsToFindUser() throws Exception {
    final QueryDatabaseAuthenticationHandler q = new QueryDatabaseAuthenticationHandler();
    q.setDataSource(this.dataSource);
    q.setSql(SQL);
    q.authenticateUsernamePasswordInternal(
            TestUtils.getCredentialsWithDifferentUsernameAndPassword("usernotfound", "psw1"));

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:QueryDatabaseAuthenticationHandlerTests.java


示例19: verifyPasswordAsAuthenticationAttributeCanDecrypt

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void verifyPasswordAsAuthenticationAttributeCanDecrypt() throws Exception {
    final Map<?, ?> attributes = renderView();
    assertTrue(attributes.containsKey(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL_CREDENTIAL));

    final String encodedPsw = (String) attributes.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL_CREDENTIAL);
    final String password = decryptCredential(encodedPsw);
    final UsernamePasswordCredential creds = TestUtils.getCredentialsWithSameUsernameAndPassword();
    assertEquals(password, creds.getPassword());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:Cas30ResponseViewTests.java


示例20: checkNoPublicKeyDefined

import org.jasig.cas.TestUtils; //导入依赖的package包/类
@Test
public void checkNoPublicKeyDefined() {
    final Service service = TestUtils.getService("testDefault");
    final CasAttributeEncoder encoder = new DefaultCasAttributeEncoder(this.servicesManager);
    final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, service);
    assertEquals(encoded.size(), this.attributes.size() - 2);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:DefaultCasAttributeEncoderTests.java



注:本文中的org.jasig.cas.TestUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComposedImage类代码示例发布时间:2022-05-23
下一篇:
Java WeiboAuth类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap