Exemplo n.º 1
0
def test_verify_file_instance_bad_acl(app):
    """verify_file_instance returns True if the key has a bad URL, but fixes it."""
    with app.app_context():
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        key.set_acl('public-read')
        assert grooming.verify_file_instance(DATA_DIGEST, len(DATA), key)
Exemplo n.º 2
0
def test_verify_file_instance(app):
    """verify_file_instance returns True if the size and digest match"""
    with app.app_context():
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        assert grooming.verify_file_instance(DATA_DIGEST, len(DATA), key)
Exemplo n.º 3
0
def test_verify_file_instance_bad_storage_class(app):
    """verify_file_instance returns False if the key's storage class is not STANDARD."""
    with app.app_context():
        key = make_key(
            app, 'us-east-1', 'tt-use1', DATA_KEY, DATA, storage_class='RRS')
        assert not grooming.verify_file_instance(DATA_DIGEST, len(DATA), key)
Exemplo n.º 4
0
def test_verify_file_instance_bad_digest(app):
    """verify_file_instance returns False if the digests are different"""
    with app.app_context():
        bogus_digest = hashlib.sha512(os.urandom(len(DATA))).hexdigest()
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        assert not grooming.verify_file_instance(bogus_digest, len(DATA), key)
Exemplo n.º 5
0
def test_verify_file_instance_bad_size(app):
    """verify_file_instance returns False if the sizes are different"""
    with app.app_context():
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        assert not grooming.verify_file_instance(
            DATA_DIGEST, len(DATA) + 2, key)
Exemplo n.º 6
0
def test_verify_file_instance_bad_digest(app):
    """verify_file_instance returns False if the digests are different"""
    with app.app_context():
        bogus_digest = hashlib.sha512(os.urandom(len(DATA))).hexdigest()
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        assert not grooming.verify_file_instance(bogus_digest, len(DATA), key)
Exemplo n.º 7
0
def test_verify_file_instance_bad_size(app):
    """verify_file_instance returns False if the sizes are different"""
    with app.app_context():
        key = make_key(app, 'us-east-1', 'tt-use1', DATA_KEY, DATA)
        assert not grooming.verify_file_instance(DATA_DIGEST,
                                                 len(DATA) + 2, key)