Expose locust port, add csrf support, and fix app_links
This commit is contained in:
parent
c5c667a436
commit
03d816884b
@ -4,4 +4,4 @@ RUN apk update && apk --no-cache add g++ gcc libxslt-dev
|
|||||||
RUN pip install pyquery
|
RUN pip install pyquery
|
||||||
USER locust
|
USER locust
|
||||||
ADD locustfile.py locustfile.py
|
ADD locustfile.py locustfile.py
|
||||||
|
EXPOSE 8089
|
||||||
|
@ -29,6 +29,11 @@ def get_index(l):
|
|||||||
l.client.get("/")
|
l.client.get("/")
|
||||||
|
|
||||||
|
|
||||||
|
def get_csrf_token(response):
|
||||||
|
d = pq(response.text)
|
||||||
|
return d("#csrf_token").val()
|
||||||
|
|
||||||
|
|
||||||
def get_portfolios(l):
|
def get_portfolios(l):
|
||||||
response = l.client.get("/portfolios")
|
response = l.client.get("/portfolios")
|
||||||
d = pq(response.text)
|
d = pq(response.text)
|
||||||
@ -71,7 +76,7 @@ def get_app(l):
|
|||||||
l.client.get(app_link)
|
l.client.get(app_link)
|
||||||
else:
|
else:
|
||||||
portfolio_id = choice(l.locust.portfolio_links).split("/")[-2]
|
portfolio_id = choice(l.locust.portfolio_links).split("/")[-2]
|
||||||
update_app_registry(l, portfolio_id, create_new_app(l, portfolio_id))
|
update_app_registry(l, portfolio_id, [create_new_app(l, portfolio_id)])
|
||||||
|
|
||||||
|
|
||||||
def pick_app(l):
|
def pick_app(l):
|
||||||
@ -80,24 +85,26 @@ def pick_app(l):
|
|||||||
|
|
||||||
|
|
||||||
def create_new_app(l, portfolio_id):
|
def create_new_app(l, portfolio_id):
|
||||||
|
create_app_url = f"/portfolios/{portfolio_id}/applications/new"
|
||||||
|
new_app_form = l.client.get(create_app_url)
|
||||||
|
|
||||||
create_app_body = {
|
create_app_body = {
|
||||||
"name": f"Load Test Created - {''.join(choices(LETTERS, k=5))}",
|
"name": f"Load Test Created - {''.join(choices(LETTERS, k=5))}",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
|
"csrf_token": get_csrf_token(new_app_form),
|
||||||
}
|
}
|
||||||
|
|
||||||
create_app_url = f"/portfolios/{portfolio_id}/applications/new"
|
|
||||||
|
|
||||||
create_app_response = l.client.post(create_app_url, create_app_body)
|
create_app_response = l.client.post(create_app_url, create_app_body)
|
||||||
|
|
||||||
application_id = create_app_response.url.split("/")[-3]
|
|
||||||
|
|
||||||
create_environments_body = {
|
create_environments_body = {
|
||||||
"environment_names-0": "Development",
|
"environment_names-0": "Development",
|
||||||
"environment_names-1": "Testing",
|
"environment_names-1": "Testing",
|
||||||
"environment_names-2": "Staging",
|
"environment_names-2": "Staging",
|
||||||
"environment_names-3": "Production",
|
"environment_names-3": "Production",
|
||||||
|
"csrf_token": get_csrf_token(create_app_response),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
application_id = create_app_response.url.split("/")[-3]
|
||||||
create_environments_url = (
|
create_environments_url = (
|
||||||
f"/applications/{application_id}/new/step_2?portfolio_id={portfolio_id}"
|
f"/applications/{application_id}/new/step_2?portfolio_id={portfolio_id}"
|
||||||
)
|
)
|
||||||
@ -108,6 +115,7 @@ def create_new_app(l, portfolio_id):
|
|||||||
|
|
||||||
|
|
||||||
def create_portfolio(l):
|
def create_portfolio(l):
|
||||||
|
new_portfolio_form = l.client.get("/portfolios/new")
|
||||||
new_portfolio_body = {
|
new_portfolio_body = {
|
||||||
"name": f"Load Test Created - {''.join(choices(LETTERS, k=5))}",
|
"name": f"Load Test Created - {''.join(choices(LETTERS, k=5))}",
|
||||||
"defense_component": "Army, Department of the",
|
"defense_component": "Army, Department of the",
|
||||||
@ -119,6 +127,7 @@ def create_portfolio(l):
|
|||||||
"dev_team": "civilians",
|
"dev_team": "civilians",
|
||||||
"dev_team_other": "",
|
"dev_team_other": "",
|
||||||
"team_experience": "none",
|
"team_experience": "none",
|
||||||
|
"csrf_token": get_csrf_token(new_portfolio_form),
|
||||||
}
|
}
|
||||||
|
|
||||||
response = l.client.post("/portfolios", new_portfolio_body)
|
response = l.client.post("/portfolios", new_portfolio_body)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user