Esempio n. 1
0
    def test_parse_multple_embedded(self):
        data_size = 75
        count = len(headers)
        pems = []
        text = ''

        for i in moves.range(count):
            pems.append(PEM(pem_type=headers[i][0],
                            pem_header=headers[i][1],
                            data_size=data_size + i,
                            data_offset=i))

        for i in moves.range(count):
            text += 'bla bla\n'
            text += 'yada yada yada\n'
            text += pems[i].pem_text
            text += 'burfl blatz bingo\n'

        parse_results = pemutils.parse_pem(text)
        self.assertEqual(count, len(parse_results))

        for i in moves.range(count):
            r = parse_results[i]
            p = pems[i]

            self.assertEqual(p.pem_type, r.pem_type)
            self.assertEqual(p.pem_header, r.pem_header)
            self.assertEqual(p.pem_text,
                             text[r.pem_start:r.pem_end])
            self.assertEqual(p.wrapped_base64,
                             text[r.base64_start:r.base64_end])
            self.assertEqual(p.data, r.binary_data)
Esempio n. 2
0
    def test_parse_multple_find_specific(self):
        data_size = 70
        count = len(headers)
        pems = []
        text = ''

        for i in moves.range(count):
            pems.append(PEM(pem_type=headers[i][0],
                            pem_header=headers[i][1],
                            data_size=data_size + i,
                            data_offset=i))

        for i in moves.range(count):
            text += pems[i].pem_text

        for i in moves.range(count):
            parse_results = pemutils.parse_pem(text, pem_type=headers[i][0])
            self.assertEqual(1, len(parse_results))

            r = parse_results[0]
            p = pems[i]

            self.assertEqual(p.pem_type, r.pem_type)
            self.assertEqual(p.pem_header, r.pem_header)
            self.assertEqual(p.pem_text,
                             text[r.pem_start:r.pem_end])
            self.assertEqual(p.wrapped_base64,
                             text[r.base64_start:r.base64_end])
            self.assertEqual(p.data, r.binary_data)
Esempio n. 3
0
    def test_parse_one(self):
        data_size = 70
        count = len(headers)
        pems = []

        for i in moves.range(count):
            pems.append(PEM(pem_type=headers[i][0],
                            pem_header=headers[i][1],
                            data_size=data_size + i,
                            data_offset=i))

        for i in moves.range(count):
            p = pems[i]
            text = p.pem_text

            parse_results = pemutils.parse_pem(text)
            self.assertEqual(len(parse_results), 1)

            r = parse_results[0]
            self.assertEqual(p.pem_type, r.pem_type)
            self.assertEqual(p.pem_header, r.pem_header)
            self.assertEqual(p.pem_text,
                             text[r.pem_start:r.pem_end])
            self.assertEqual(p.wrapped_base64,
                             text[r.base64_start:r.base64_end])
            self.assertEqual(p.data, r.binary_data)
Esempio n. 4
0
    def test_parse_none(self):
        text = ''
        text += 'bla bla\n'
        text += 'yada yada yada\n'
        text += 'burfl blatz bingo\n'

        parse_results = pemutils.parse_pem(text)
        self.assertEqual(0, len(parse_results))

        self.assertEqual(False, pemutils.is_pem(text))
Esempio n. 5
0
    def test_parse_one_embedded(self):
        p = PEM(data_offset=0)
        text = ""
        text += "bla bla\n"
        text += "yada yada yada\n"
        text += p.pem_text
        text += "burfl blatz bingo\n"

        parse_results = pemutils.parse_pem(text)
        self.assertEqual(1, len(parse_results))

        r = parse_results[0]
        self.assertEqual(p.pem_type, r.pem_type)
        self.assertEqual(p.pem_header, r.pem_header)
        self.assertEqual(p.pem_text, text[r.pem_start : r.pem_end])
        self.assertEqual(p.wrapped_base64, text[r.base64_start : r.base64_end])
        self.assertEqual(p.data, r.binary_data)
Esempio n. 6
0
    def test_parse_one_embedded(self):
        p = PEM(data_offset=0)
        text = ''
        text += 'bla bla\n'
        text += 'yada yada yada\n'
        text += p.pem_text
        text += 'burfl blatz bingo\n'

        parse_results = pemutils.parse_pem(text)
        self.assertEqual(1, len(parse_results))

        r = parse_results[0]
        self.assertEqual(p.pem_type, r.pem_type)
        self.assertEqual(p.pem_header, r.pem_header)
        self.assertEqual(p.pem_text, text[r.pem_start:r.pem_end])
        self.assertEqual(p.wrapped_base64, text[r.base64_start:r.base64_end])
        self.assertEqual(p.data, r.binary_data)