This repository has been archived by the owner on Aug 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathauthenticate-and-revoke.lua
63 lines (56 loc) · 1.66 KB
/
authenticate-and-revoke.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Script that authenticates a user against Vault's userpass system
-- and then revokes the lease many times
local counter = 1
local threads = {}
function setup(thread)
thread:set("id", counter)
table.insert(threads, thread)
counter = counter + 1
end
function init(args)
requests = 0
authentications = 0
revocations = 0
responses = 0
local msg = "thread %d created"
print(msg:format(id))
end
function request()
requests = requests + 1
if requests > 3 and requests % 2 == 0 then
-- Authenticate
authentications = authentications + 1
method = "POST"
path = "/v1/auth/userpass/login/loadtester"
body = '{"password" : "benchmark" }'
-- print("Authenticating")
else
-- Revoke lease
revocations = revocations + 1
method = "PUT"
path = "/v1/sys/leases/revoke-prefix/auth/userpass/login/loadtester"
body = ''
-- print("Revoking")
end
return wrk.format(method, path, nil, body)
end
function delay()
return 0
end
function response(status, headers, body)
if status == 200 or status == 204 then
responses = responses + 1
end
-- print("Status: " .. status)
end
function done(summary, latency, requests)
for index, thread in ipairs(threads) do
local id = thread:get("id")
local requests = thread:get("requests")
local authentications = thread:get("authentications")
local revocations = thread:get("revocations")
local responses = thread:get("responses")
local msg = "thread %d made %d authentications and %d revocations and got %d responses"
print(msg:format(id, authentications, revocations, responses))
end
end