Skip to content

Commit

Permalink
✅ [#1865] Add basic locust performance test for Mijn aanvragen
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Jan 15, 2024
1 parent 615d7e1 commit 1fa64e9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions performance-tests/locustfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from urllib.parse import urlencode

from locust import HttpUser, events, task


class OpenInwonerUser(HttpUser):
wait_time = lambda _: 0.5

@task
def mijn_aanvragen_list_cached(self):
self.client.get("/mijn-aanvragen/content", headers={"HX-Request": "true"})

def on_start(self):
params = urlencode(
{
"acs": f"{self.host}/digid/acs/",
"next": self.host,
"cancel": f"{self.host}/accounts/login/",
}
)
digid_login_url = f"/digid/idp/inloggen_ww/?{params}"

response = self.client.get(digid_login_url)
csrftoken = response.cookies["csrftoken"]

self.client.post(
digid_login_url,
data={
"auth_name": self.bsn,
"auth_pass": "foo",
"csrfmiddlewaretoken": csrftoken,
"commit": "Inloggen",
},
)

# Ensure uncached call is logged separately
self.client.get(
"/mijn-aanvragen/content?_uncached=true", headers={"HX-Request": "true"}
)


@events.init_command_line_parser.add_listener
def init_parser(parser):
parser.add_argument("--bsn", type=str, dest="bsn", help="BSN used to login with")


@events.init.add_listener
def on_locust_init(environment, **kwargs):
OpenInwonerUser.bsn = environment.parsed_options.bsn

0 comments on commit 1fa64e9

Please sign in to comment.