Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-rs committed Aug 9, 2024
1 parent f718e55 commit d3846be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions test/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from assemblyline.common import forge
from assemblyline.odm.messages.submission import Submission
from assemblyline.odm.models.config import HASH_PATTERN_MAP
from assemblyline.odm.models.config import HASH_PATTERN_MAP, DEFAULT_SUBMISSION_PROFILES
from assemblyline.odm.models.file import File
from assemblyline.odm.randomizer import random_model_obj, get_random_phrase
from assemblyline.odm.random_data import create_users, wipe_users, create_services, wipe_services
Expand Down Expand Up @@ -345,12 +345,13 @@ def test_ingest_submission_profile(datastore, login_session, scheduler):
get_api_data(session, f"{host}/api/v4/ingest/", method="POST", data=json.dumps(data))

# Try using a submission profile with no parameters
data['submission_profile'] = "Static Analysis"
profile = DEFAULT_SUBMISSION_PROFILES[0]
data['submission_profile'] = profile["name"]
get_api_data(session, f"{host}/api/v4/ingest/", method="POST", data=json.dumps(data))

# Try using a submission profile with a parameter you aren't allowed to set
# The system should silently ignore your parameter and still create a submission
data['params'] = {'deep_scan': True}
data['params'] = {'services': ['blah']}
get_api_data(session, f"{host}/api/v4/ingest/", method="POST", data=json.dumps(data))

# Restore original roles for later tests
Expand Down
9 changes: 5 additions & 4 deletions test/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conftest import get_api_data, APIError

from assemblyline.common import forge
from assemblyline.odm.models.config import HASH_PATTERN_MAP
from assemblyline.odm.models.config import HASH_PATTERN_MAP, DEFAULT_SUBMISSION_PROFILES
from assemblyline.odm.random_data import create_users, wipe_users, create_submission, wipe_submissions
from assemblyline.odm.randomizer import get_random_phrase
from assemblyline.remote.datatypes.queues.named import NamedQueue
Expand Down Expand Up @@ -301,14 +301,15 @@ def test_submit_submission_profile(datastore, login_session, scheduler):
get_api_data(session, f"{host}/api/v4/submit/", method="POST", data=json.dumps(data))

# Try using a submission profile with no parameters
data['submission_profile'] = "Static Analysis"
profile = DEFAULT_SUBMISSION_PROFILES[0]
data['submission_profile'] = profile["name"]
get_api_data(session, f"{host}/api/v4/submit/", method="POST", data=json.dumps(data))

# Try using a submission profile with a parameter you aren't allowed to set
# The system should silently ignore your parameter and still create a submission
data['params'] = {'deep_scan': True}
data['params'] = {'services': ['blah']}
resp = get_api_data(session, f"{host}/api/v4/submit/", method="POST", data=json.dumps(data))
assert resp['params']['deep_scan'] == False
assert resp['params']['services'] == profile['services']

# Restore original roles for later tests
datastore.user.update('admin', [(datastore.user.UPDATE_REMOVE, 'type', 'user'),
Expand Down

0 comments on commit d3846be

Please sign in to comment.