<commit_before>from django.test import TestCase
from breach.models import SampleSet, Victim, Target, Round
from breach.analyzer import decide_next_world_state


class AnalyzerTestCase(TestCase):
    def setUp(self):
        target = Target.objects.create(
            endpoint='http://di.uoa.gr/',
            prefix='test',
            alphabet='0123456789'
        )
        victim = Victim.objects.create(
            target=target,
            sourceip='192.168.10.140',
            snifferendpoint='http://localhost/'
        )
        round = Round.objects.create(
            victim=victim,
            amount=1,
            knownsecret='testsecret',
            knownalphabet='01'
        )
        self.samplesets = [
            SampleSet.objects.create(
                round=round,
                candidatealphabet='0',
                data='bigbigbigbigbigbig'
            ),
            SampleSet.objects.create(
                round=round,
                candidatealphabet='1',
                data='small'
            )
        ]

    def test_decide(self):
        state, confidence = decide_next_world_state(self.samplesets)

        self.assertEqual(state["knownsecret"], "testsecret1")<commit_msg>Create base test case class for rupture<commit_after>from django.test import TestCase
from breach.models import SampleSet, Victim, Target, Round
from breach.analyzer import decide_next_world_state


class RuptureTestCase(TestCase):
    def setUp(self):
        target = Target.objects.create(
            endpoint='http://di.uoa.gr/',
            prefix='test',
            alphabet='0123456789'
        )
        victim = Victim.objects.create(
            target=target,
            sourceip='192.168.10.140',
            snifferendpoint='http://localhost/'
        )
        round = Round.objects.create(
            victim=victim,
            amount=1,
            knownsecret='<PASSWORD>',
            knownalphabet='01'
        )
        self.samplesets = [
            SampleSet.objects.create(
                round=round,
                candidatealphabet='0',
                data='bigbigbigbigbigbig'
            ),
            SampleSet.objects.create(
                round=round,
                candidatealphabet='1',
                data='small'
            )
        ]

class AnalyzerTestCase(RuptureTestCase):
    def test_decide(self):
        state, confidence = decide_next_world_state(self.samplesets)

        self.assertEqual(state["knownsecret"], "testsecret1")
{'fraction_non_alphanumeric': 0.10015961691939346, 'fraction_numerical': 0.02154828411811652, 'mean_word_length': 1.7886540600667409, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7450825', 'n_tokens_mistral': 704, 'n_tokens_neox': 657, 'n_words': 109}