<commit_before>""" test (de)armoring of PGP blocks
"""
import pytest

import glob
import os
from datetime import datetime, timedelta

from pgpy.constants import HashAlgorithm
from pgpy.constants import PubKeyAlgorithm
from pgpy.constants import SignatureType
from pgpy.pgp import PGPKey
from pgpy.pgp import PGPMessage
from pgpy.pgp import PGPSignature
from pgpy.types import Armorable

blocks = sorted(glob.glob('tests/testdata/blocks/*.asc'))
block_attrs = {
    'tests/testdata/blocks/message.ascii.asc':
        [('encrypters',    set()),
         ('filename',      'ascii'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       "This is stored, textually!\r\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.compressed.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', True),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.literal.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.onepass.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2A834D8E5918E886'}),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.two_onepass.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.signed.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>'}),
         ('message',      b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',         'literal'),],

    'tests/testdata/blocks/cleartext.asc':
        [('encrypters',    set()),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>'}),
         ('message',       "This is stored, literally\\!\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',          'cleartext'),],

    'tests/testdata/blocks/cleartext.twosigs.asc':
        [('encrypters',    set()),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>', 'A<PASSWORD>'}),
         ('message',       "This is stored, literally\\!\n"),
         ('signers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('type',          'cleartext'),],

    'tests/testdata/blocks/message.encrypted.asc':
        [('encrypters',    {'EEE097A017B979CA'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'EEE097A017B979CA'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/message.encrypted.signed.asc':
        [('encrypters',    {'EEE097A017B979CA'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'EEE097A017B979CA'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/message.ecc.encrypted.asc':
        [('encrypters',    {'77CEB7A34089AB73'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'77CEB7A34089AB73'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/revochiio.asc':
        [('created',       datetime.utcnow() - timedelta(days=1),
         ('fingerprint',   "AE15 9FF3 4C1A 2426 B7F8 0F1A 560C F308 EF60 CFA3"),
         ('expires_at',    datetime.utcnow() + timedelta(days=1),
         ('is_expired',    False),
         ('is_primary',    True),
         ('is_protected',  False),
         ('is_public',     True),
         ('is_unlocked',   True),
         ('key_algorithm', PubKeyAlgorithm.RSAEncryptOrSign),
         ('magic',         "PUBLIC KEY BLOCK"),
         ('parent',        None),
         ('signers',       {'560CF308EF60CFA3'}),],

    'tests/testdata/blocks/expyro.asc':
        [('created',       datetime(1970, 1, 1)),
         ('expires_at',    datetime(1970, 1, 2)),
         ('fingerprint',   '24EB C1B0 29B1 FCF8 29A5  C150 1A48 291A FB91 A533'),
         ('is_expired',    True),],

    'tests/testdata/blocks/rsapubkey.asc':
        [('created',       datetime(2014, 7, 23, 21, 19, 24)),
         ('expires_at',    None),<commit_msg>tests/test_03_armor.py: fix syntax<commit_after>""" test (de)armoring of PGP blocks
"""
import pytest

import glob
import os
from datetime import datetime, timedelta

from pgpy.constants import HashAlgorithm
from pgpy.constants import PubKeyAlgorithm
from pgpy.constants import SignatureType
from pgpy.pgp import PGPKey
from pgpy.pgp import PGPMessage
from pgpy.pgp import PGPSignature
from pgpy.types import Armorable

blocks = sorted(glob.glob('tests/testdata/blocks/*.asc'))
block_attrs = {
    'tests/testdata/blocks/message.ascii.asc':
        [('encrypters',    set()),
         ('filename',      'ascii'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       "This is stored, textually!\r\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.compressed.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', True),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.literal.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     False),
         ('issuers',       set()),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       set()),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.onepass.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>'}),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.two_onepass.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('message',       b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('type',          'literal'),],

    'tests/testdata/blocks/message.signed.asc':
        [('encrypters',    set()),
         ('filename',      'lit'),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>'}),
         ('message',      b"This is stored, literally\\!\n\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',         'literal'),],

    'tests/testdata/blocks/cleartext.asc':
        [('encrypters',    set()),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>'}),
         ('message',       "This is stored, literally\\!\n"),
         ('signers',       {'2<PASSWORD>'}),
         ('type',          'cleartext'),],

    'tests/testdata/blocks/cleartext.twosigs.asc':
        [('encrypters',    set()),
         ('is_compressed', False),
         ('is_encrypted',  False),
         ('is_signed',     True),
         ('issuers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('message',       "This is stored, literally\\!\n"),
         ('signers',       {'2<PASSWORD>', '<PASSWORD>'}),
         ('type',          'cleartext'),],

    'tests/testdata/blocks/message.encrypted.asc':
        [('encrypters',    {'EEE097A017B979CA'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'EEE097A017B979CA'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/message.encrypted.signed.asc':
        [('encrypters',    {'EEE097A017B979CA'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'EEE097A017B979CA'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/message.ecc.encrypted.asc':
        [('encrypters',    {'77CEB7A34089AB73'}),
         ('is_compressed', False),
         ('is_encrypted',  True),
         ('is_signed',     False),
         ('issuers',       {'77CEB7A34089AB73'}),
         ('signers',       set()),
         ('type',          'encrypted')],

    'tests/testdata/blocks/revochiio.asc':
        [('created',       datetime.utcnow() - timedelta(days=1)),
         ('fingerprint',   "AE15 9FF3 4C1A 2426 B7F8 0F1A 560C F308 EF60 CFA3"),
         ('expires_at',    datetime.utcnow() + timedelta(days=1)),
         ('is_expired',    False),
         ('is_primary',    True),
         ('is_protected',  False),
         ('is_public',     True),
         ('is_unlocked',   True),
         ('key_algorithm', PubKeyAlgorithm.RSAEncryptOrSign),
         ('magic',         "PUBLIC KEY BLOCK"),
         ('parent',        None),
         ('signers',       {'560CF308EF60CFA3'}),],

    'tests/testdata/blocks/expyro.asc':
        [('created',       datetime(1970, 1, 1)),
         ('expires_at',    datetime(1970, 1, 2)),
         ('fingerprint',   '24EB C1B0 29B1 FCF8 29A5  C150 1A48 291A FB91 A533'),
         ('is_expired',    True),],

    'tests/testdata/blocks/rsapubkey.asc':
        [('created',       datetime(2014, 7, 23, 21, 19, 24)),
         ('expires_at',    None),
{'fraction_non_alphanumeric': 0.19066080813302316, 'fraction_numerical': 0.02696648574136297, 'mean_word_length': 1.9589599796074433, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3478161', 'n_tokens_mistral': 3848, 'n_tokens_neox': 3660, 'n_words': 679}