iriusrisk / bdd-security

BDD Automated Security Tests for Web Applications
http://www.continuumsecurity.net/bdd-intro.html
GNU Affero General Public License v3.0
563 stars 178 forks source link

Issues with getting the authorisation feature to work #50

Closed streichsbaer closed 8 years ago

streichsbaer commented 8 years ago

Hey Stephen,

as you know, I've been taking a closer look at BDD-Security recently and am loving it. After getting the authentication and some other features to work well, I've been playing around with the authorisation feature and have problems getting it to work.

A clip from the cucumber test pretty report looks like this.

cucumber results_export

For some reason it skips

14:22:02.159 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the login page STARTED
14:22:02.163 [DEBUG] [TestEventLogger] 
14:22:02.163 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the login page PASSED
14:22:02.168 [DEBUG] [TestEventLogger] 
14:22:02.168 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the username jack@metacorp.com STARTED
14:22:02.169 [DEBUG] [TestEventLogger] 
14:22:02.169 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the username jack@metacorp.com SKIPPED
14:22:02.171 [DEBUG] [TestEventLogger] 
14:22:02.171 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the password yankeessuck STARTED
14:22:02.176 [DEBUG] [TestEventLogger] 
14:22:02.176 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.And the password yankeessuck SKIPPED
14:22:02.180 [DEBUG] [TestEventLogger] 
14:22:02.180 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.When the user logs in STARTED
14:22:02.181 [DEBUG] [TestEventLogger] 
14:22:02.181 [DEBUG] [TestEventLogger] net.continuumsecurity.junit.SecurityTest > | viewJacksInfo | jack@metacorp.com | yankeessuck | Jack Mannin |.When the user logs in SKIPPED

The authorisation.feature file can be seen below. I'm testing BDD-Security on RailsGoat currently. authorisation.feature.feature.txt

Finally, my current RailsGoatApplication.java file is attached below: RailsGoatApplication.java.txt

Looking at the line And the username it doesn't seem to have an according WebApplicationSteps.java mapping. There is one for @Given but not for @And. I've even tried mix and matching the keywords, but without success.

@Given("^the username (\\s+)$")
    public void setUsernameFromExamples(String username) {
        World.getInstance().getUserPassCredentials().setUsername(username);
    }

Any idea what needs to be done to make it work?

Thanks, Stefan

streichsbaer commented 8 years ago

FYI, I ran the default authorisation feature of bdd-security config against ropeytasks.jar and have similar results as mentioned above.

bdd-security-vs-ropeytasks_authorisation
iriusrisk commented 8 years ago

Thanks @streichsbaer I've reproduced the same error in RopeyTasks. Investigating now.

iriusrisk commented 8 years ago

Was a regex problem, fixed with: @Given("^the username (.*)$")

and:

@Given("^the password (.*)$")

Have tested it with RopeyTasks, let me know whether it works for RailsGoat.

streichsbaer commented 8 years ago

Thanks for the fast response. I was wondering about the regex, but because it seemed to show up correctly in the steps I thought it's alright. I'm going to test once I am back home.

streichsbaer commented 8 years ago

Excellent, all working now! Thank you.

railsgoat_overview railsgoat_authorisation
iriusrisk commented 8 years ago

Great to hear! New feature requests/pull requests welcome :)