List of usage examples for org.springframework.http HttpMethod OPTIONS
HttpMethod OPTIONS
To view the source code for org.springframework.http HttpMethod OPTIONS.
Click Source Link
From source file:de.codecentric.boot.admin.web.CorsFilterOnSamePortsTest.java
@Test public void testCORS_OPTIONS_jolokia_endpoint() { // DO serve CORS-Headers on management-endpoints ResponseEntity<Void> options = new TestRestTemplate().exchange( "http://localhost:" + serverPort + "/jolokia", HttpMethod.OPTIONS, HttpEntity.EMPTY, Void.class); assertEquals(HttpStatus.OK, options.getStatusCode()); assertEquals(Arrays.asList("*"), options.getHeaders().get("Access-Control-Allow-Origin")); assertEquals(Arrays.asList("Origin, X-Requested-With, Content-Type, Accept"), options.getHeaders().get("Access-Control-Allow-Headers")); }
From source file:com.mec.Security.WebSecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().cors().and().sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests() .antMatchers(HttpMethod.POST, "/login/**").permitAll().antMatchers(HttpMethod.OPTIONS, "/**") .permitAll().and() // **permit OPTIONS call to all** .authorizeRequests().antMatchers("/API/editor/**").hasAnyRole("mapa.Editor").and() .addFilterBefore(jwtLoginFilter(), UsernamePasswordAuthenticationFilter.class)//filter the api/login requests .addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);// And filter other requests to check the presence of JWT in header }
From source file:com.github.lynxdb.server.api.http.WebSecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable();//from w ww . j av a 2s . c om http.antMatcher("/api/**").authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll() .antMatchers(EpAggregators.ENDPOINT, EpQuery.ENDPOINT, EpSuggest.ENDPOINT) .hasAnyRole(User.Rank.RO_USER.name(), User.Rank.RW_USER.name(), User.Rank.ADMIN.name()) .antMatchers(HttpMethod.POST, EpPut.ENDPOINT) .hasAnyRole(User.Rank.RW_USER.name(), User.Rank.ADMIN.name()) .antMatchers(EpUser.ENDPOINT, EpVhost.ENDPOINT).hasRole(User.Rank.ADMIN.name()); http.httpBasic().realmName("Lynx"); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); }
From source file:de.codecentric.boot.admin.web.CorsFilterOnDifferentPortsTest.java
@Test public void testCORS_OPTIONS_jolokia_endpoint() { // DO serve CORS-Headers on management-endpoints ResponseEntity<Void> options = new TestRestTemplate().exchange( "http://localhost:" + managementPort + "/jolokia", HttpMethod.OPTIONS, HttpEntity.EMPTY, Void.class); assertEquals(HttpStatus.OK, options.getStatusCode()); assertEquals(Arrays.asList("*"), options.getHeaders().get("Access-Control-Allow-Origin")); assertEquals(Arrays.asList("Origin, X-Requested-With, Content-Type, Accept"), options.getHeaders().get("Access-Control-Allow-Headers")); }
From source file:org.androidannotations.test15.rest.HttpMethodServiceTest.java
@Test @SuppressWarnings("unchecked") public void useOptionsHttpMethod() { HttpMethodsService_ service = new HttpMethodsService_(null); RestTemplate restTemplate = mock(RestTemplate.class); ResponseEntity<Object> response = mock(ResponseEntity.class); when(restTemplate.exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any())).thenReturn(response); HttpHeaders headers = mock(HttpHeaders.class); when(response.getHeaders()).thenReturn(headers); service.setRestTemplate(restTemplate); service.options();/*from ww w .j a va 2 s . c o m*/ verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any()); }
From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerListControllerITCase.java
@Test public void testOptions() throws Exception { this.mockMvc// w ww. j av a2 s . c o m .perform(request(HttpMethod.OPTIONS, "http://localhost/customer/") .contentType(HalHttpMessageConverter.HAL_JSON).accept(HalHttpMessageConverter.HAL_JSON)) .andExpect(status().isOk()).andExpect(header().string("Allow", "GET,POST,HEAD")).andReturn(); }
From source file:net.eusashead.hateoas.springhalbuilder.controller.OrderListControllerITCase.java
@Test public void testOptions() throws Exception { this.mockMvc/* w ww . j a v a2 s . co m*/ .perform(request(HttpMethod.OPTIONS, "http://localhost/order/") .contentType(HalHttpMessageConverter.HAL_JSON).accept(HalHttpMessageConverter.HAL_JSON)) .andExpect(status().isOk()).andExpect(header().string("Allow", "GET,POST,HEAD")).andReturn(); }
From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerControllerITCase.java
@Test public void testOptions() throws Exception { this.mockMvc/*from w w w .ja v a2 s .c om*/ .perform(request(HttpMethod.OPTIONS, "http://localhost/customer/1") .contentType(HalHttpMessageConverter.HAL_JSON).accept(HalHttpMessageConverter.HAL_JSON)) .andExpect(status().isOk()).andExpect(header().string("Allow", "GET,HEAD")).andReturn(); }
From source file:net.eusashead.hateoas.springhalbuilder.controller.OrderControllerITCase.java
@Test public void testOptions() throws Exception { this.mockMvc//from w w w . ja v a 2 s .com .perform(request(HttpMethod.OPTIONS, "http://localhost/order/1") .contentType(HalHttpMessageConverter.HAL_JSON).accept(HalHttpMessageConverter.HAL_JSON)) .andExpect(status().isOk()).andExpect(header().string("Allow", "GET,HEAD")).andReturn(); }
From source file:es.galvarez.rest.config.SpringSecurityConfiguration.java
@Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http.exceptionHandling().authenticationEntryPoint(basicAuthenticationEntryPoint()).and().sessionManagement() .enableSessionUrlRewriting(false).sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/api/**").permitAll().and() .authorizeRequests().antMatchers("/api/**").authenticated().and().httpBasic() .authenticationEntryPoint(basicAuthenticationEntryPoint()).and().csrf().disable(); // @formatter:on }