use of org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder in project cas by apereo.
the class Cas20ResponseViewTests method verifyView.
@Test
public void verifyView() throws Exception {
val modelAndView = this.getModelAndViewUponServiceValidationWithSecurePgtUrl(RegisteredServiceTestUtils.getService("https://www.casinthecloud.com"));
val req = new MockHttpServletRequest(new MockServletContext());
req.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, new GenericWebApplicationContext(req.getServletContext()));
val resp = new MockHttpServletResponse();
val delegatedView = new View() {
@Override
public String getContentType() {
return MediaType.TEXT_HTML_VALUE;
}
@Override
public void render(final Map<String, ?> map, final HttpServletRequest request, final HttpServletResponse response) {
map.forEach(request::setAttribute);
}
};
val view = new Cas20ResponseView(true, new NoOpProtocolAttributeEncoder(), null, delegatedView, new DefaultAuthenticationAttributeReleasePolicy("attribute"), new DefaultAuthenticationServiceSelectionPlan(), NoOpProtocolAttributesRenderer.INSTANCE);
view.render(modelAndView.getModel(), req, resp);
assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_CHAINED_AUTHENTICATIONS));
assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRIMARY_AUTHENTICATION));
assertNotNull(req.getAttribute(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL));
assertNotNull(req.getAttribute(CasProtocolConstants.VALIDATION_CAS_MODEL_PROXY_GRANTING_TICKET_IOU));
}
use of org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder in project cas by apereo.
the class Cas10ResponseViewTests method verifyFailureView.
@Test
public void verifyFailureView() throws Exception {
val response = new MockHttpServletResponse();
val view = new Cas10ResponseView(false, new NoOpProtocolAttributeEncoder(), mock(ServicesManager.class), mock(AuthenticationAttributeReleasePolicy.class), new DefaultAuthenticationServiceSelectionPlan(), NoOpProtocolAttributesRenderer.INSTANCE);
view.render(this.model, new MockHttpServletRequest(), response);
assertEquals("no\n\n", response.getContentAsString());
}
use of org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder in project cas by apereo.
the class Cas30JsonResponseViewTests method verifyFailureView.
@Test
public void verifyFailureView() throws Exception {
val response = new MockHttpServletResponse();
val view = getCasView(false, new NoOpProtocolAttributeEncoder(), getDelegatedView());
val model = new HashMap<String, Object>();
model.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_CODE, "code");
model.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION, "description");
val request = new MockHttpServletRequest();
view.render(model, request, response);
val casResponse = (CasJsonServiceResponse) request.getAttribute(Cas30JsonResponseView.ATTRIBUTE_NAME_MODEL_SERVICE_RESPONSE);
assertNotNull(casResponse.getAuthenticationFailure().getCode());
assertNotNull(casResponse.getAuthenticationFailure().getDescription());
}
use of org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder in project cas by apereo.
the class Saml10SuccessResponseViewTests method initialize.
@BeforeEach
public void initialize() {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val list = new ArrayList<RegisteredService>();
list.add(RegisteredServiceTestUtils.getRegisteredService("https://.+"));
val dao = new InMemoryServiceRegistry(appCtx, list, new ArrayList<>());
val context = ServicesManagerConfigurationContext.builder().serviceRegistry(dao).applicationContext(appCtx).environments(new HashSet<>(0)).servicesCache(Caffeine.newBuilder().build()).registeredServiceLocators(List.of(new DefaultServicesManagerRegisteredServiceLocator())).build();
val mgmr = new DefaultServicesManager(context);
mgmr.load();
val protocolAttributeEncoder = new DefaultCasProtocolAttributeEncoder(mgmr, CipherExecutor.noOpOfStringToString());
val builder = new Saml10ObjectBuilder(configBean);
val samlResponseBuilder = new SamlResponseBuilder(builder, "testIssuer", "whatever", 1000, "PT30S", new NoOpProtocolAttributeEncoder(), mgmr);
this.response = new Saml10SuccessResponseView(protocolAttributeEncoder, mgmr, new DefaultArgumentExtractor(new SamlServiceFactory()), StandardCharsets.UTF_8.name(), new DefaultAuthenticationAttributeReleasePolicy("attribute"), new DefaultAuthenticationServiceSelectionPlan(), NoOpProtocolAttributesRenderer.INSTANCE, samlResponseBuilder);
}
use of org.apereo.cas.authentication.support.NoOpProtocolAttributeEncoder in project cas by apereo.
the class Saml10FailureResponseViewTests method initialize.
@BeforeEach
public void initialize() {
val builder = new Saml10ObjectBuilder(this.configBean);
val samlResponseBuilder = new SamlResponseBuilder(builder, null, null, 0, "PT30S", new NoOpProtocolAttributeEncoder(), null);
view = new Saml10FailureResponseView(new NoOpProtocolAttributeEncoder(), null, new DefaultArgumentExtractor(new SamlServiceFactory()), StandardCharsets.UTF_8.name(), null, new DefaultAuthenticationServiceSelectionPlan(), NoOpProtocolAttributesRenderer.INSTANCE, samlResponseBuilder);
}
Aggregations