use of org.springframework.ui.Model in project Asqatasun by Asqatasun.
the class LoginControllerTest method testDisplayLoginPage.
/**
* Test of displayLoginPage method, of class LoginController.
*/
public void testDisplayLoginPage() {
System.out.println("displayLoginPage");
Model model = new ExtendedModelMap();
setUpMockAuthenticationContext();
LoginController instance = new LoginController();
String expResult = TgolKeyStore.LOGIN_VIEW_NAME;
String result = instance.displayLoginPage("", new HttpServletRequest() {
@Override
public String getAuthType() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Cookie[] getCookies() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getDateHeader(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getHeader(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Enumeration getHeaders(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Enumeration getHeaderNames() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getIntHeader(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getMethod() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPathInfo() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPathTranslated() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getContextPath() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getQueryString() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRemoteUser() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isUserInRole(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Principal getUserPrincipal() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRequestedSessionId() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRequestURI() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StringBuffer getRequestURL() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getServletPath() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HttpSession getSession(boolean bln) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HttpSession getSession() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isRequestedSessionIdValid() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isRequestedSessionIdFromCookie() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isRequestedSessionIdFromURL() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isRequestedSessionIdFromUrl() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object getAttribute(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Enumeration getAttributeNames() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getCharacterEncoding() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setCharacterEncoding(String string) throws UnsupportedEncodingException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getContentLength() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getContentType() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ServletInputStream getInputStream() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getParameter(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Enumeration getParameterNames() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String[] getParameterValues(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Map getParameterMap() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getProtocol() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getScheme() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getServerName() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getServerPort() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public BufferedReader getReader() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRemoteAddr() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRemoteHost() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAttribute(String string, Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeAttribute(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Locale getLocale() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Enumeration getLocales() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isSecure() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public RequestDispatcher getRequestDispatcher(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getRealPath(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getRemotePort() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getLocalName() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getLocalAddr() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getLocalPort() {
throw new UnsupportedOperationException("Not supported yet.");
}
}, model);
assertEquals(expResult, result);
}
use of org.springframework.ui.Model in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditUploadSetUp.
public void testDisplayPageAuditUploadSetUp() {
System.out.println("testDisplayPageAuditUploadSetUp");
// Set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
setUpViewFunctionalityBindingMap();
setUpAuditSetUpCommandFactory();
Model model = new ExtendedModelMap();
// test
String returnedView = instance.displayUploadAuditSetUp("1", null, null, model);
// assertions
assertEquals(TgolKeyStore.AUDIT_UPLOAD_SET_UP_VIEW_NAME, returnedView);
assertEquals("http://www.test1.com", model.asMap().get(TgolKeyStore.URL_KEY));
assertEquals(false, model.asMap().get(TgolKeyStore.DEFAULT_PARAM_SET_KEY));
}
use of org.springframework.ui.Model in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditSiteSetUp.
public void testDisplayPageAuditSiteSetUp() {
System.out.println("testDisplayPageAuditSiteSetUp");
// Set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
setUpViewFunctionalityBindingMap();
setUpAuditSetUpCommandFactory();
Model model = new ExtendedModelMap();
String returnedView = instance.displaySiteAuditSetUp("1", null, null, model);
// assertions
assertEquals(TgolKeyStore.AUDIT_SITE_SET_UP_VIEW_NAME, returnedView);
assertEquals("http://www.test1.com", model.asMap().get(TgolKeyStore.URL_KEY));
assertEquals(true, model.asMap().get(TgolKeyStore.DEFAULT_PARAM_SET_KEY));
}
use of org.springframework.ui.Model in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditPageSetUp.
public void testDisplayPageAuditPageSetUp() {
System.out.println("testDisplayPageAuditPageSetUp");
// set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
setUpViewFunctionalityBindingMap();
setUpAuditSetUpCommandFactory();
Model model = new ExtendedModelMap();
// test
String returnedView = instance.displayPageAuditSetUp("1", null, null, model);
// assertions
assertEquals(TgolKeyStore.AUDIT_PAGE_SET_UP_VIEW_NAME, returnedView);
assertEquals("http://www.test1.com", model.asMap().get(TgolKeyStore.URL_KEY));
assertEquals(false, model.asMap().get(TgolKeyStore.DEFAULT_PARAM_SET_KEY));
// TO DO : write test to control the integrity of data of the AuditSetUpCommand
// regarding the option/functionality rules
}
use of org.springframework.ui.Model in project cas by apereo.
the class OidcJwksEndpointController method handleRequestInternal.
/**
* Handle request for jwk set.
*
* @param request the request
* @param response the response
* @param model the model
* @return the jwk set
* @throws Exception the exception
*/
@GetMapping(value = '/' + OidcConstants.BASE_OIDC_URL + '/' + OidcConstants.JWKS_URL, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response, final Model model) throws Exception {
Assert.notNull(this.jwksFile, "JWKS file cannot be undefined or null.");
try {
final String jsonJwks = IOUtils.toString(this.jwksFile.getInputStream(), StandardCharsets.UTF_8);
final JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jsonJwks);
getServicesManager().getAllServices().stream().filter(s -> s instanceof OidcRegisteredService && StringUtils.isNotBlank(((OidcRegisteredService) s).getJwks())).forEach(Unchecked.consumer(s -> {
final OidcRegisteredService service = (OidcRegisteredService) s;
final Resource resource = this.resourceLoader.getResource(service.getJwks());
final JsonWebKeySet set = new JsonWebKeySet(IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8));
set.getJsonWebKeys().forEach(jsonWebKeySet::addJsonWebKey);
}));
final String body = jsonWebKeySet.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
return new ResponseEntity<>(body, HttpStatus.OK);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}
}
Aggregations