How to check if a redirect is received, it is not redirecting to BLAH

I have a request that is part of an OAUTH login process. Possible results are:

200 - a message of some kind - (I have not seen what, yet).
302 - redirect to Authorize page
302 - redirect to Not Authorized page
302 - redirect to Application main page

The redirect to Not Authorized page is a problem, and the .check() should fail in that case.

How can I compose a .check() that, if header(“Location”) is found, it must not match some pattern, or contain some substring?

I thought it would be something like this:

`
.check( header(“Location”).transformOption( _ match {
case None => Some(true)
case Some(s) => if ( s.contains("/security/not-eligible") ) Some(false) else Some(true)
}).is( true )

`

But I get a compile error:

missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)

I’ve tried several other syntactic structures, but no luck so far. What is the right way of doing this?

I answered this very same question today in another thread :slight_smile:

Mind pointing me to that thread? I’ve read everything (at groups.google.com), and I’m not seeing it! :stuck_out_tongue:

The closest thing to discussing this subject I can find is where you pointed out that if you don’t disableFollowRedirect, then you will never see the header. That’s not my problem. I’m struggling to get it to compile.

I managed to get it to compile like this:

`
.check(
header(“Location”)
.transformOption( extract =>
extract.map( ! _.contains("/security/not-eligible") ) )
.is( true )
)

`

But while it compiles, it doesn’t function correctly. I need it to pass the check if the Location header is not present, and fail if it exists and contains the string, otherwise, pass.

Okay, now I’m starting to get annoyed. I made a minor, seemingly insignificant tweak, and suddenly it compiles…

`
.check(
header(“Location”)
.transformOption( extract => extract match {
case None => Some(true)
case Some(x) => Some( ! x.contains( “/security/not-eligible” ) )
}).is( true ) )

`

Can you tell me why this compiles, but my first code sample did not?

Please check this thread: https://groups.google.com/forum/#!msg/gatling/znJZBdEwOsM/ktdwXjQjnSsJ

Thanks. That’s the one I found. That wasn’t my issue.

I was struggling with getting the compiler to understand my code. PEBKAC. Problem Exists Between Keyboard And Chair. :slight_smile:

OK.
Glad you managed to solve it by yourself. :slight_smile: