@Test void testInitWithoutUser() { MockHttpServletRequest request = new MockHttpServletRequest(); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); assertEquals("view-swagger-ui", swaggerController.init(model)); verify(model).addAttribute("molgenisUrl", "http: verify(model).addAttribute("baseUrl", "http: verifyNoMoreInteractions(model); }
@GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); final String currentUsername = SecurityUtils.getCurrentUsername(); if (currentUsername != null) { model.addAttribute( "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI")); } return "view-swagger-ui"; }
SwaggerController extends PluginController { @GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); final String currentUsername = SecurityUtils.getCurrentUsername(); if (currentUsername != null) { model.addAttribute( "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI")); } return "view-swagger-ui"; } }
SwaggerController extends PluginController { @GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); final String currentUsername = SecurityUtils.getCurrentUsername(); if (currentUsername != null) { model.addAttribute( "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI")); } return "view-swagger-ui"; } SwaggerController(MetaDataService metaDataService, TokenService tokenService); }
SwaggerController extends PluginController { @GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); final String currentUsername = SecurityUtils.getCurrentUsername(); if (currentUsername != null) { model.addAttribute( "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI")); } return "view-swagger-ui"; } SwaggerController(MetaDataService metaDataService, TokenService tokenService); @GetMapping String init(Model model); @GetMapping(value = "/swagger.yml", produces = "text/yaml") String swagger(Model model, HttpServletResponse response); }
SwaggerController extends PluginController { @GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); final String currentUsername = SecurityUtils.getCurrentUsername(); if (currentUsername != null) { model.addAttribute( "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI")); } return "view-swagger-ui"; } SwaggerController(MetaDataService metaDataService, TokenService tokenService); @GetMapping String init(Model model); @GetMapping(value = "/swagger.yml", produces = "text/yaml") String swagger(Model model, HttpServletResponse response); static final String URI; }