Skip to content
Open
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
24 changes: 14 additions & 10 deletions backend/breach/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ def setUp(self):
prefix='test',
alphabet='0123456789'
)
self.victim = Victim.objects.create(
target=target,
sourceip='192.168.10.140',
snifferendpoint='http://localhost/'
)

self.victim = self.create_mock_victim(target)

round = Round.objects.create(
victim=self.victim,
amount=1,
Expand All @@ -35,11 +33,8 @@ def setUp(self):
]

# Balance checking
self.balance_victim = Victim.objects.create(
target=target,
sourceip='192.168.10.141',
snifferendpoint='http://localhost/'
)
self.balance_victim = self.create_mock_victim(target)

balance_round = Round.objects.create(
victim=self.balance_victim,
amount=1,
Expand All @@ -61,6 +56,15 @@ def setUp(self):
)
]

def create_mock_victim(self, target):

mock_victim = Victim.objects.create(
target=target,
sourceip='192.168.10.140',
snifferendpoint='http://localhost/'
)
return mock_victim

def tearDown(self):
for sampleset in self.balance_samplesets + self.samplesets:
sampleset.completed = timezone.now()
Expand Down
25 changes: 23 additions & 2 deletions backend/breach/tests/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,29 @@ def test_first_round(self, Sniffer):

strategy1._mark_current_work_completed()

def test_same_round_same_batch(self):
pass
@patch('breach.strategy.Sniffer')
def test_same_round_same_batch(self, Sniffer):

# Mock initial round
mock_target = Target.objects.create(
endpoint='https://di.uoa.gr/?breach=%s',
prefix='test',
alphabet='01',
name='twitter',
alignmentalphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)

victim = self.create_mock_victim(mock_target)

strategy0 = Strategy(victim)
work0 = strategy0.get_work()
strategy0._mark_current_work_completed()

strategy1 = Strategy(victim)
work1 = strategy1.get_work()
strategy1._mark_current_work_completed()

self.assertEqual(work0['alignmentalphabet'], work1['alignmentalphabet'])

@patch('breach.strategy.Sniffer')
def test_same_round_different_batch(self, Sniffer):
Expand Down