List of usage examples for org.openqa.selenium Cookie Cookie
public Cookie(String name, String value, String path)
From source file:net.continuumsecurity.web.TeamMentorWSTest.java
License:Open Source License
public Cookie getCookieByName(String name) { Client client = ClientProxy.getClient(port); client.getEndpoint().getOutInterceptors().add(new SoapActionInterceptor()); HTTPConduit http = (HTTPConduit) client.getConduit(); if (http.getCookies() == null || http.getCookies().size() == 0) return null; org.apache.cxf.transport.http.Cookie cookie = http.getCookies().get(name); Cookie returnCookie = new Cookie(cookie.getName(), cookie.getValue(), cookie.getPath()); return returnCookie; }
From source file:org.keycloak.testsuite.adapter.servlet.DemoServletsAdapterTest.java
License:Apache License
@Test public void testInvalidTokenCookie() { // Login/* w w w . j a v a 2 s . c o m*/ String tokenCookie = loginToCustomerCookiePortal(); String changedTokenCookie = tokenCookie.replace("a", "b"); // change cookie to invalid value driver.manage().addCookie(new Cookie(AdapterConstants.KEYCLOAK_ADAPTER_STATE_COOKIE, changedTokenCookie, "/customer-cookie-portal")); // visit page and assert re-logged and cookie was refreshed customerCookiePortal.navigateTo(); assertCurrentUrlEquals(customerCookiePortal); String currentCookie = driver.manage().getCookieNamed(AdapterConstants.KEYCLOAK_ADAPTER_STATE_COOKIE) .getValue(); assertNotEquals(currentCookie, tokenCookie); assertNotEquals(currentCookie, changedTokenCookie); // logout logoutFromCustomerCookiePortal(); }