Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions ci/apiv2/hashtopolis_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def print_to_log(*args): # noqa:E301
http.client.print = print_to_log


def _load_config():
load_order = (str(Path(__file__).parent.joinpath('{name}-defaults{suffix}')),) \
+ confidence.DEFAULT_LOAD_ORDER
return confidence.load_name('hashtopolis-test', load_order=load_order, format=confidence.YAML())


class ProcessState(enum.IntEnum):
""" See src/inc/defines/hashcat.php for mapping"""
INIT = 0
Expand All @@ -46,9 +52,7 @@ class ProcessState(enum.IntEnum):
class HashtopolisConfig(object):
def __init__(self):
# Request access TOKEN, used throughout the test
load_order = (str(Path(__file__).parent.joinpath('{name}-defaults{suffix}')),) \
+ confidence.DEFAULT_LOAD_ORDER
self._cfg = confidence.load_name('hashtopolis-test', load_order=load_order, format=confidence.YAML())
self._cfg = _load_config()
self._hashtopolis_uri = self._cfg['hashtopolis_uri']
self._api_endpoint = self._hashtopolis_uri + '/api/v2'
self.username = self._cfg['username']
Expand All @@ -60,9 +64,7 @@ class DummyAgent(object):
# State: Early Alpha
def __init__(self, token=None, voucher=None):
# Request access TOKEN, used throughout the test
load_order = (str(Path(__file__).parent.joinpath('{name}-defaults{suffix}')),) \
+ confidence.DEFAULT_LOAD_ORDER
self._cfg = confidence.load_name('hashtopolis-test', load_order=load_order, format=confidence.YAML())
self._cfg = _load_config()
self._hashtopolis_uri = self._cfg['hashtopolis_uri']
self._api_endpoint = self._hashtopolis_uri + '/api/server.php'

Expand Down
9 changes: 2 additions & 7 deletions ci/apiv2/test_agent_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@

from hashtopolis import Agent, Config, HealthCheck, Voucher
from hashtopolis_agent import DummyAgent
from utils import BaseTest, do_create_agentassignent, do_create_dummy_agent, do_create_voucher
from utils import BaseTest, do_create_agentassignent, do_create_dummy_agent, do_create_voucher, get_hashtopolis_uri


AGENT_ENDPOINT = '/api/server.php'


def _uri():
"""Return the configured server base URI (resolved the same way as BaseTest)."""
from pathlib import Path
import confidence
load_order = (str(Path(__file__).parent.joinpath('{name}-defaults.{extension}')),) \
+ confidence.DEFAULT_LOAD_ORDER
cfg = confidence.load_name('hashtopolis-test', load_order=load_order)
return cfg['hashtopolis_uri']
return get_hashtopolis_uri()


def agent_request(payload):
Expand Down
2 changes: 1 addition & 1 deletion ci/apiv2/test_apitoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_token_scope_admin_grants_requested(self):
"""Admin holds every legacy permission, so any requested scope must be granted in the JWT."""
model_obj = self.create_test_object()
scope = _decode_jwt_scope(model_obj.token)
self.assertTrue('permHashlistRead' in scope)
self.assertTrue(scope['permHashlistRead'])

def test_token_scope_intersection_grants_permitted(self):
"""A restricted user is granted a requested scope they hold via the legacy permission mapping."""
Expand Down
Loading