List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:com.nobu.dvdrentalweb.test.restapi.AccountRestControllerTest.java
@Test public void testreadAcountsClubById() { String accountName = "Savings"; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Account> responseEntity = restTemplate.exchange(URL + "api/account/name/" + accountName, HttpMethod.GET, requestEntity, Account.class); Account account = responseEntity.getBody(); Assert.assertNotNull(account);/*from www .j a va 2 s . c o m*/ }
From source file:at.ac.univie.isc.asio.security.HttpMethodRestrictionFilterTest.java
@Test public void should_keep_other_token_properties() throws Exception { final TestingAuthenticationToken token = new TestingAuthenticationToken("user", "secret", Collections.<GrantedAuthority>singletonList(Permission.INVOKE_UPDATE)); token.setDetails("details"); setAuthentication(token);//w ww. j ava 2 s . co m request.setMethod(HttpMethod.GET.name()); subject.doFilter(request, response, chain); final Authentication filtered = getAuthentication(); assertThat(filtered.getPrincipal(), equalTo(token.getPrincipal())); assertThat(filtered.getCredentials(), equalTo(token.getCredentials())); assertThat(filtered.getDetails(), equalTo(token.getDetails())); }
From source file:de.zib.gndms.gndmc.utils.HTTPGetter.java
public int get(String url, final HttpHeaders headers) throws NoSuchAlgorithmException, KeyManagementException { return get(HttpMethod.GET, url, headers); }
From source file:rest.ApplianceRestController.java
@Test public void testreadApplianceById() { String clubId = "1"; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Appliance> responseEntity = restTemplate.exchange(URL + "api/app/id/" + clubId, HttpMethod.GET, requestEntity, Appliance.class); Appliance app = responseEntity.getBody(); Assert.assertNotNull(app);/* ww w .j a v a 2 s.com*/ }
From source file:com.expedia.seiso.SeisoWebSecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http/*from ww w .ja va2s .c o m*/ // TODO Would prefer to do this without sessions if possible. But see // https://spring.io/guides/tutorials/spring-security-and-angular-js/ // http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-sticky-sessions.html // .sessionManagement() // .sessionCreationPolicy(SessionCreationPolicy.STATELESS) // .and() .authorizeRequests().antMatchers(HttpMethod.GET, "/internal/**").permitAll() .antMatchers(HttpMethod.GET, "/api/**").permitAll().antMatchers(HttpMethod.POST, "/api/**") .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.PUT, "/api/**") .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.DELETE, "/api/**") .hasAnyRole(Roles.USER, Roles.ADMIN).antMatchers(HttpMethod.PATCH, "/api/**") .hasAnyRole(Roles.USER, Roles.ADMIN) // Admin console .antMatchers(HttpMethod.GET, "/admin").hasRole(Roles.ADMIN).antMatchers(HttpMethod.GET, "/admin/**") .hasRole(Roles.ADMIN) // Blacklist .anyRequest().denyAll() // .anyRequest().hasRole(Roles.USER) .and().httpBasic().authenticationEntryPoint(entryPoint()).and().exceptionHandling() .authenticationEntryPoint(entryPoint()).and() // FIXME Enable. See https://spring.io/guides/tutorials/spring-security-and-angular-js/ .csrf().disable(); // @formatter:on }
From source file:org.shaigor.rest.retro.service.security.config.OAuth2SecurityConfigurer.java
@Override public void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/login.jsp").permitAll().and().authorizeRequests().anyRequest() .hasRole("USER").and().exceptionHandling().accessDeniedPage("/login.jsp?authorization_error=true") .and()// w w w . ja va2 s. co m // TODO: put CSRF protection back into this endpoint .csrf().requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/authorize")).disable() .logout().logoutSuccessUrl("/index.jsp").logoutUrl("/logout.do").and().authorizeRequests() .regexMatchers(HttpMethod.GET, "/word/list(\\?.*)?") // .access("hasIpAddress('127.0.0.1') or (#oauth2.hasScope('words') and hasRole('ROLE_USER'))") .access("#oauth2.hasScope('words') and hasRole('ROLE_USER')").and().formLogin() .usernameParameter("j_username").passwordParameter("j_password") .failureUrl("/login.jsp?authentication_error=true").loginPage("/login.jsp") .loginProcessingUrl("/j_spring_security_check"); }
From source file:org.zalando.github.spring.MembersTemplateTest.java
@Test public void isNotMember() throws Exception { mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/members/klaus")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withStatus(NOT_FOUND)); boolean answer = membersTemplate.isMemberOfOrganization("zalando-stups", "klaus"); Assertions.assertThat(answer).isFalse(); }
From source file:fragment.web.AuthenticationControllerTest.java
@Test public void testLandingRouting() throws Exception { logger.debug("Testing routing...."); DispatcherTestServlet servlet = getServletInstance(); Method expected = locateMethod(controller.getClass(), "login", new Class[] { HttpServletRequest.class, ModelMap.class, HttpSession.class }); Method handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/login")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "loggedout", new Class[] { java.lang.String.class, ModelMap.class, HttpSession.class, HttpServletResponse.class, HttpServletRequest.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/userParam/loggedout")); Assert.assertEquals(expected, handler); MockHttpServletRequest request = getRequestTemplate(HttpMethod.GET, "/reset_password"); expected = locateMethod(controller.getClass(), "requestReset", new Class[] { ModelMap.class, }); handler = servlet.recognize(request); Assert.assertEquals(expected, handler); request.removeAllParameters();/* w ww . j a v a2 s.com*/ request.addParameter("username", "value"); request.setMethod(HttpMethod.POST.name()); expected = locateMethod(controller.getClass(), "requestReset", new Class[] { String.class, HttpServletRequest.class, ModelMap.class }); handler = servlet.recognize(request); Assert.assertEquals(expected, handler); request.removeAllParameters(); request.setMethod(HttpMethod.GET.name()); request.addParameter("a", "value"); request.addParameter("t", "0"); request.addParameter("i", "value"); expected = locateMethod(controller.getClass(), "reset", new Class[] { String.class, Long.TYPE, String.class, HttpSession.class, ModelMap.class }); handler = servlet.recognize(request); Assert.assertEquals(expected, handler); request.removeAllParameters(); request.addParameter("password", "password"); request.setMethod(HttpMethod.POST.name()); expected = locateMethod(controller.getClass(), "reset", new Class[] { String.class, HttpSession.class, HttpServletRequest.class }); handler = servlet.recognize(request); Assert.assertEquals(expected, handler); request.removeAllParameters(); expected = locateMethod(controller.getClass(), "requestCall", new Class[] { String.class, String.class, HttpServletRequest.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/request_call_by_user")); Assert.assertEquals(expected, handler); request.removeAllParameters(); expected = locateMethod(controller.getClass(), "requestSMS", new Class[] { String.class, String.class, HttpServletRequest.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/request_sms_by_user")); Assert.assertEquals(expected, handler); request.removeAllParameters(); expected = locateMethod(controller.getClass(), "verifyAdditionalEmail", new Class[] { String.class, String.class, String.class, HttpServletRequest.class, ModelMap.class, HttpSession.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/verify_additional_email")); Assert.assertEquals(expected, handler); request.removeAllParameters(); expected = locateMethod(controller.getClass(), "getGoogleAnalytics", new Class[] {}); handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/getGoogleAnalytics")); Assert.assertEquals(expected, handler); }
From source file:com.joseph.california.test.restapi.ClubRestControllerTest.java
@Test public void testgetAllClubs() { HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Club[]> responseEntity = restTemplate.exchange(URL + "api/club/clubs", HttpMethod.GET, requestEntity, Club[].class); Club[] clubs = responseEntity.getBody(); for (Club club : clubs) { System.out.println("The Club Name is " + club.getName()); }/*from w w w . ja v a2s . c om*/ Assert.assertTrue(clubs.length > 0); }
From source file:com.ecsteam.cloudlaunch.services.jenkins.JenkinsService.java
public QueuedBuildResponse getJobNumberFromQueue(String queueId) { RestTemplate template = new RestTemplate(); QueuedBuildResponse response = null; // let's just be 100% sure that we don't enter an infinite loop (almost certainly never would) // we have to continuously check this URL because the queued item goes away quickly, so we need // to get the job number ASAP for (int count = 0; count < 1000; ++count) { ResponseEntity<QueueItemResponseFragment> fragmentEntity = template.exchange( "{baseUrl}/queue/item/{queueId}/api/json", HttpMethod.GET, getAuthorizationEntity(), QueueItemResponseFragment.class, baseUrl, queueId); if (!HttpStatus.OK.equals(fragmentEntity.getStatusCode())) { return null; }/*w w w .j a va 2s .com*/ QueueItemResponseFragment fragment = fragmentEntity.getBody(); if (fragment.getExecutable() != null && fragment.getExecutable().getUrl() != null) { String monitorUrl = fragment.getExecutable().getUrl(); String last = null; String current = null; String next = null; String[] parts = monitorUrl.split("/"); response = new QueuedBuildResponse(); for (int i = parts.length - 1; i >= 0; --i) { last = parts[i]; current = parts[i - 1]; next = parts[i - 2]; if ("job".equals(next) && jobName.equals(current)) { response = new QueuedBuildResponse(); response.setMonitorUri(String.format("/services/builds/job/%s", last)); return response; } } } } return null; }