Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix login server name in gatling tests.

Also added a vmc failed login scenario and some other
minor changes.

Change-Id: I65f66226db754bf1f5b824278d7b69e26fd6826e
  • Loading branch information...
commit 538b3d86d0e8932a8bad763d228f5360af980202 1 parent 473a82b
@tekul tekul authored
View
9 gatling/src/main/scala/AccountLockoutSimulation.scala
@@ -12,12 +12,11 @@ import uaa.OAuthComponents._
class AccountLockoutSimulation extends Simulation {
val lockoutScenario = scenario("Account Lockout")
- .feed(UniqueUsernamePasswordFeeder(users, Some("wrongpass")))
- .loop(
- chain.exec(vmcLogin("${username}", "${password}", "read", 401))
+ .feed(UniqueUsernamePasswordFeeder(users))
+ .repeat(10)(
+ chain.exec(vmcLoginFailure())
)
- .times(10)
- .pause(60*5) // 5 mins
+ .pause(61*5) // 5 mins 5 secs
.exec((s:Session) => {
s.setAttribute("password", "password") // use the right password
})
View
10 gatling/src/main/scala/UaaSmokeSimulation.scala
@@ -36,6 +36,13 @@ class UaaSmokeSimulation extends Simulation {
// .exec((s: Session) => {println("User: %s, token: %s" format(s.getAttribute("username"), s.getAttribute("access_token"))); s})
}
+ val vmcFailedLogins = scenario("VMC Failed Login")
+ .during(Duration) {
+ chain.feed(UsernamePasswordFeeder())
+ .exec(vmcLoginFailure())
+ .pause(0, 2000, TimeUnit.MILLISECONDS)
+ }
+
val random = new scala.util.Random()
val randomUserFeeder = new Feeder() {
@@ -81,9 +88,10 @@ class UaaSmokeSimulation extends Simulation {
Seq(
uiLoginLogout.configure users 2 ramp 10 protocolConfig loginHttpConfig
, scimWorkout.configure users 10 ramp 10 protocolConfig uaaHttpConfig
- , authzCodeLogin.configure users 5 ramp 10 protocolConfig loginHttpConfig
+ , authzCodeLogin.configure users 10 ramp 10 protocolConfig loginHttpConfig
, passwordScores.configure users 1 ramp 10 protocolConfig uaaHttpConfig
, vmcUserLogins.configure users 10 ramp 10 protocolConfig uaaHttpConfig
+ , vmcFailedLogins.configure users 5 protocolConfig uaaHttpConfig
)
}
}
View
2  gatling/src/main/scala/uaa/Config.scala
@@ -79,7 +79,7 @@ object Config {
}
def loginHttpConfig = {
- val loginUrl = baseUrl map (prependHttp) map (_.replace("://", "://lgn.")) getOrElse "http://localhost:8080/uaa"
+ val loginUrl = baseUrl map (prependHttp) map (_.replace("://", "://login.")) getOrElse "http://localhost:8080/uaa"
println("**** Targeting Login server at: " + loginUrl)
httpConfig.baseURL(loginUrl).disableFollowRedirect.disableAutomaticReferer.warmUp(loginUrl)
}
View
42 gatling/src/main/scala/uaa/OAuthComponents.scala
@@ -124,30 +124,26 @@ object OAuthComponents {
.check(status.is(200), jsonToken.saveAs("access_token"))
/**
- * Action which performs an implicit token request as VMC client.
- *
- * Requires a username and password in the session.
- */
- def vmcLogin(): ActionBuilder = vmcLogin("${username}", "${password}")
-
- /**
- * Single vmc login action with a specific username/password and scope
+ * Single vmc login action with a specific username/password
*/
- def vmcLogin(username: String, password: String, scope: String = "", expectedStatus:Int = 302): ActionBuilder = {
- val ab = http("VMC login")
- .post("/oauth/authorize")
- .param("client_id", "vmc")
- .param("scope", scope)
- .param("credentials", """{"username":"%s","password":"%s"}""".format(username, password))
- .param("redirect_uri", "http://uaa.cloudfoundry.com/redirect/vmc")
- .param("response_type", "token")
- .headers(plainHeaders)
- if (expectedStatus == 302) {
- ab.check(status is 302, fragmentToken.saveAs("access_token"))
- } else {
- ab.check(status is expectedStatus)
- }
- }
+ def vmcLogin(username: String = "${username}", password: String = "${password}"): ActionBuilder =
+ vmcAction("VMC login", username, password)
+ .check(status is 302, fragmentToken.saveAs("access_token"))
+
+ def vmcLoginFailure(username: String = "${username}", password: String = "pXssword"): ActionBuilder =
+ vmcAction("VMC failed login", username, password)
+ .check(status is 401)
+
+ private def vmcAction(name: String, username: String, password: String) =
+ http(name)
+ .post("/oauth/authorize")
+ .param("client_id", "vmc")
+ .param("source", "credentials")
+ .param("username", username)
+ .param("password", password)
+ .param("redirect_uri", "http://uaa.cloudfoundry.com/redirect/vmc")
+ .param("response_type", "token")
+ .headers(plainHeaders)
def login: ActionBuilder = login("${username}", "${password}")
Please sign in to comment.
Something went wrong with that request. Please try again.