grooveondemand/test/test_ondemand.py

32 lines
696 B
Python
Raw Normal View History

2022-11-19 16:58:58 -08:00
import os
import sys
import atheris
from boddle import boddle
2022-11-19 16:58:58 -08:00
from groove import ondemand
2022-11-19 16:58:58 -08:00
def test_server():
with boddle():
assert ondemand.index() == 'Groovy.'
2022-11-19 16:58:58 -08:00
def test_auth_with_valid_credentials():
with boddle(auth=(os.environ.get('USERNAME'), os.environ.get('PASSWORD'))):
assert ondemand.admin() == 'Authenticated. Groovy.'
2022-11-19 16:58:58 -08:00
def test_auth_random_input():
def auth(fuzzed_input):
with boddle(auth=(fuzzed_input, fuzzed_input)):
result = ondemand.admin()
assert result.body == 'Access denied'
atheris.Setup([sys.argv[0], "-atheris_runs=100000"], auth)
try:
atheris.Fuzz()
except SystemExit:
pass