Beispiel #1
0
 def test_parse_timestamps(self, case):
     fail_regex, *verdicts = case
     rcv = tstamp.TstampReceiver(config=self.cfg)
     if fail_regex:
         self.check_timestamp_fails(rcv, verdicts[-1], fail_regex)
         rcv.force = True
     self.check_timestamp(rcv, *verdicts)
Beispiel #2
0
        def sign_validator(self) -> tstamp.TstampReceiver:
            sign_validator = getattr(request, 'sign_validator', None)
            if sign_validator is None:
                request.sign_validator = sign_validator = tstamp.TstampReceiver(
                    config=self.traits_config)

            return sign_validator
Beispiel #3
0
 def test_criteria_stripping(self, case):
     ecrts, one, projects = case
     rcv = tstamp.TstampReceiver(rfc_criteria=ecrts,
                                 wait_criterio=one,
                                 subject_prefix=one)
     crt = rcv._prepare_search_criteria(True, projects)
     self.assertEqual(crt, '')
Beispiel #4
0
 def test_parse_missing_pub_key_tag(self):
     rcv = tstamp.TstampReceiver(config=self.cfg)
     verdict = rcv.parse_signed_tag(missing_pub_key_tag)
     print(yaml.dump(verdict, indent=2))
     self.assertFalse(verdict['valid'], verdict)
     self.assertEqual(verdict['status'], 'no public key')
     self.assertIn(missing_pub_key_id, verdict['key_id'], verdict)
Beispiel #5
0
 def test_parse_signed_tag(self):
     rcv = tstamp.TstampReceiver(config=self.cfg)
     verdict = rcv.parse_signed_tag(signed_tag)
     sverdict = yaml.dump(verdict, indent=2)
     self.assertTrue(verdict['valid'], sverdict)
     self.assertIn(crypto._TEST_KEY_ID, verdict['fingerprint'], sverdict)
     self.assertEqual(verdict['commit_msg']['p'], 'FT-12-ABC-2016-0001',
                      sverdict)
Beispiel #6
0
    def test_criteria_dupe_projects(self):
        rcv = tstamp.TstampReceiver(rfc_criteria=[], subject_prefix='')
        crt = rcv._prepare_search_criteria(False, [])  # sanity
        self.assertEqual(crt, '')

        crt = rcv._prepare_search_criteria(False, ['ab', 'ab'])
        self.assertNotIn('OR', crt)

        crt = rcv._prepare_search_criteria(False, ['ab', 'foo', 'ab'])
        self.assertEqual(crt.count('OR'), 1)
Beispiel #7
0
 def test_parse_missing_pub_key_decision(self):
     cfg = self.cfg.copy()
     cfg.Spec.force = True
     rcv = tstamp.TstampReceiver(config=cfg)
     verdict = rcv.parse_tstamp_response(missing_pub_key_decision)
     print(yaml.dump(verdict, indent=2))
     self.assertTrue(verdict['tstamp']['valid'])
     self.assertFalse(verdict['report']['valid'])
     self.assertEqual(verdict['report']['status'], 'no public key')
     self.assertIn(missing_pub_key_id, verdict['report']['key_id'])
Beispiel #8
0
    def test_extract_base64_blob(self):
        tag_text = """Τιριρερεμ"""
        snd = tstamp.TstampSender(config=self.cfg)
        snd.scramble_tag = True
        b64_text = snd._scramble_tag(tag_text, 'Hi there')
        self.assertTrue(all(ord(c) < 128 for c in b64_text), b64_text)
        self.assertTrue(all(len(l) < 78 for l in b64_text.split('\n')),
                        b64_text)

        rcv = tstamp.TstampReceiver(config=self.cfg)
        tstamp_text = 'Some\nFobar\r\n%s\r\n\n' % b64_text
        new_tag_text = rcv._descramble_tag(tstamp_text)
        self.assertEqual(tag_text, new_tag_text.decode('utf-8'))
Beispiel #9
0
    def test_parse_stamps(self):
        cfg = trtc.Config()
        cfg.TstampReceiver.force = True
        signer = self._SigChain(cfg=cfg)
        trecv = tstamp.TstampReceiver(config=cfg)
        chain = signer.load_stamp_chain()

        errors = []
        for sig_hex in chain:
            try:
                stamp = signer.load_sig_file(sig_hex)
                _verdict = trecv.parse_tstamp_response(stamp)
                #print(_verdict)
            except Exception as ex:
                errors.append(ex)

        assert len(errors) == 0
Beispiel #10
0
 def test_parse_timestamp_bad(self):
     rcv = tstamp.TstampReceiver(config=self.cfg)
     ex_msg = (r"Cannot verify timestamp-response's signature due to: "
               "error - verify 4294967295")
     with self.assertRaisesRegex(tstamp.CmdException, ex_msg):
         rcv.parse_tstamp_response("")
Beispiel #11
0
 def test_extract_tag_name(self, case):
     subject, msg, tag = case
     rcv = tstamp.TstampReceiver(config=self.cfg)
     tag_name = rcv.extract_dice_tag_name(subject, msg)
     self.assertEqual(tag_name, tag)
Beispiel #12
0
 def test_scan_vfid_regex(self, case):
     rcv = tstamp.TstampReceiver(config=self.cfg)
     vfid = rcv.scan_for_project_name(case[-1])
     exp_vfid = (case[4]['project'], case[4].get('vehicle_family_id'))
     self.assertIn(vfid, exp_vfid)