Created
January 24, 2015 10:31
-
-
Save ivanursul/78404db87c2d2334db55 to your computer and use it in GitHub Desktop.
AccessDeniedIntegrationTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.lnu.is.integration.access | |
import io.gatling.core.Predef.checkBuilder2Check | |
import io.gatling.core.Predef.doIf | |
import io.gatling.core.Predef.exec | |
import io.gatling.core.Predef.findCheckBuilder2ValidatorCheckBuilder | |
import io.gatling.core.Predef.foreach | |
import io.gatling.core.Predef.feed | |
import io.gatling.core.Predef.stringToExpression | |
import io.gatling.core.Predef.validatorCheckBuilder2CheckBuilder | |
import io.gatling.core.Predef.value2Expression | |
import io.gatling.core.Predef.value2Success | |
import io.gatling.http.Predef.http | |
import io.gatling.http.Predef.jsonPath | |
import io.gatling.core.Predef.csv | |
import io.gatling.core.Predef.jsonFile | |
import io.gatling.http.Predef.status | |
import io.gatling.http.request.builder.HttpRequestBuilder.toActionBuilder | |
import scala.concurrent.duration.DurationInt | |
object AccessDeniedIntegrationTest { | |
val urls = List("/persons/types", "/streets/types", "/timeperiods/types","/papers/types" , | |
"/orders/types", "/marriedtypes", "/languages", "/gendertypes", "/honors/types", | |
"/enrolments/types", "/enrolments/subjects", "/enrolments/statustypes", | |
"/eduformtypes", "/educations/types", "/departments/types", "/courses/types", | |
"/contacts/types", "/assets/types", "/assets/statuses", "/assets/states", "/adminunits", "/addresstypes") | |
val testCase = | |
exec(session => { | |
session.set("urls", urls); | |
}) | |
.foreach("${urls}", "url") { | |
exec(http("Access Denied Get Paged Result") | |
.get("${url}") | |
.basicAuth("admin", "nimda") | |
.check(status.is(200)) | |
.check(jsonPath("$.resources[*]").ofType[Map[String, Any]].findAll.saveAs("resources"))) | |
.foreach("${resources}", "resource"){ | |
exec( session => { | |
val resource = session("resource").as[Map[String, Any]] | |
println("AccessDeniedIntegrationTest:" + resource); | |
val resourceId = resource("id") | |
session.set("resourceId", resourceId) | |
}) | |
.exec( | |
http("Checking Access Denied Request Access") | |
.get("${url}/${resourceId}") | |
.basicAuth("broken_student", "nevdaha") | |
.check(status.is(403)) | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment