1

I'm have a Spring service like this:

localhost:8889/projectX/insurance/?policy=1

@RestController
@RequestMapping(value="insurance")
public class InsuranceService {

            @RequestMapping(value="/", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
            public List<Policy> getPolicy(@RequestParam(value="policy") int policy){
           ...
    }
 }

That produces a JSON with a policy info.

In WebSecurityConfig.java i have this security:

       @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
            .authorizeRequests()
            .antMatchers("/insurance/**").access("hasRole('advicer')")
            ...

So if I try to consume that service on SoapUI I will be directed to login form

SoapUi How can I consume that service correctly with authentication?

  • 1
    It is not REST if it requires form authentication. – holmis83 Jan 09 '17 at 15:03
  • Possible duplicate of [Sending cookie as request header in SOAP UI request for rest web service](http://stackoverflow.com/questions/28022721/sending-cookie-as-request-header-in-soap-ui-request-for-rest-web-service) – Alan Hay Jan 09 '17 at 19:58

1 Answers1

1

I would switch off security for Junit testing, with a profile.

In your WebSecurityConfig.java file add

@Profile("default")

Then for non security testing either in Junit use

@ActiveProfiles("test")

Or from a server add to your server start up

-Dspring.profiles.active=test
Essex Boy
  • 7,565
  • 2
  • 21
  • 24