Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
composer.lock
.DS_Store
.phpunit.result.cache
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ matrix:
- php: 7.2.24
env:
- ILLUMINATE_VERSION=6.0.*
- php: 7.2.24
env:
- ILLUMINATE_VERSION=7.0.*
- php: 7.2.24
env:
- ILLUMINATE_VERSION=^6.0
- php: 7.3
env:
- ILLUMINATE_VERSION=^6.0
- php: 7.3
env:
- ILLUMINATE_VERSION=^7.0
- php: 7.4
env:
- ILLUMINATE_VERSION=^7.0
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright (c) 2019 Marcus Olsson <contact@marcusolsson.me>
Copyright (c) 2020 Marcus Olsson <contact@marcusolsson.me>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Backup Shield simply listens for when the .zip-file generated by Laravel-backup
composer require olssonm/laravel-backup-shield
```

Requires `PHP: "^7.1"` and `laravel/framework: "^5.8"`. Compatible with Laravel 6.
Supports `laravel/framework: "^5.8"` and above (including Laravel 6 & 7.) Requires `PHP: "^7.1"`.

Please note that `spatie/laravel-backup: "^6"` and `laravel/framework: "^6.0"` requires PHP 7.2.
Please note that `spatie/laravel-backup: "^6"` and `laravel/framework: "^6.0|^7.0"` requires PHP 7.2.

## Configuration

Expand All @@ -41,7 +41,7 @@ return [

#### Password

Your password (*duh*). The default is the application key (`APP_KEY` in your .env-file). You might want to set something more appropriate. Remember to use long strings and to keep your password safe – without it you will never be able to open your backup.
Your password (*duh*). The default is the application key (`APP_KEY` in your .env-file). You might want to set something more appropriate. Remember to use long strings and to keep your password safe – **without it you will never be able to open your backup**.

Set to `NULL` if you want to keep your backup without a password.

Expand Down Expand Up @@ -82,7 +82,7 @@ $ phpunit

The MIT License (MIT). Please see the [LICENSE.md](LICENSE.md) for more information.

© 2019 [Marcus Olsson](https://marcusolsson.me).
© 2020 [Marcus Olsson](https://marcusolsson.me).

[ico-version]: https://img.shields.io/packagist/v/olssonm/laravel-backup-shield.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
],
"require": {
"php": ">=7.1",
"illuminate/support": "~5.8 || ^6.0",
"nelexa/zip": "^3.1",
"illuminate/support": "~5.8|^6.0|^7.0",
"nelexa/zip": "3.3",
"spatie/laravel-backup": "~5.0|~6.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.0",
"orchestra/testbench": "^3.8 || ^4"
"phpunit/phpunit": "^7.5|^8.0",
"orchestra/testbench": "^3.8|^4|^5"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 4 additions & 4 deletions src/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class Encryption
* @var array
*/
private $zipFileOptions = [
self::ENCRYPTION_DEFAULT => ZipFile::ENCRYPTION_METHOD_TRADITIONAL,
self::ENCRYPTION_WINZIP_AES_128 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_128,
self::ENCRYPTION_WINZIP_AES_192 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_192,
self::ENCRYPTION_WINZIP_AES_256 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_256,
self::ENCRYPTION_DEFAULT => \PhpZip\Constants\ZipEncryptionMethod::PKWARE,
self::ENCRYPTION_WINZIP_AES_128 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_128,
self::ENCRYPTION_WINZIP_AES_192 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_192,
self::ENCRYPTION_WINZIP_AES_256 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/config/backup-shield.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'encryption' => \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT

// Available encryption methods:
// \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT (PHP < 7.2: PKWARE/ZipCrypto, PHP >= 7.2 AES 128)
// \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT (PHP < 7.2: PKWARE/ZipCrypto, PHP >= 7.2: AES 128)
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_128 (AES 128)
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_192 (AES 192)
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_256 (AES 256)
Expand Down
39 changes: 31 additions & 8 deletions tests/BackupShieldTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,57 @@ public function test_listener_return_data()
$this->assertEquals($pathTest, $data[0]);
}

/** @test **/
public function test_correct_encrypter_engine()
{
$path = __DIR__ . '/resources/processed.zip';

// Use Zip-file to check attributes of the file
$zipFile = (new ZipFile())->openFile($path);
$zipInfo = $zipFile->getAllInfo();

// Assume PHP 7.2 and supporter ZipArchive
if (class_exists('ZipArchive') && in_array('setEncryptionIndex', get_class_methods('ZipArchive'))) {
$this->assertEquals(9, $zipInfo['backup.zip']->getCompressionLevel()); // 9 = ZipArchive
}
// Fallback on ZipFile
else {
$this->assertEquals(5, $zipInfo['backup.zip']->getCompressionLevel()); // 5 = ZipFile
}
}

/** @test **/
public function test_encryption_protection()
{
// Test that the archive actually is encrypted and password protected
$path = __DIR__ . '/resources/processed.zip';

// Use Zip-file to check attributes of the file
$zipFile = (new ZipFile())->openFile($path);
$zipInfo = $zipFile->getAllInfo();

$this->assertEquals(true, $zipInfo['backup.zip']->isEncrypted());
$this->assertEquals('backup.zip', $zipInfo['backup.zip']->getName());
$this->assertEquals(0, $zipInfo['backup.zip']->getEncryptionMethod());
$this->assertEquals(1, $zipInfo['backup.zip']->getEncryptionMethod());
}

/** Teardown */
public static function tearDownAfterClass(): void
{
// Delete config and test-files
unlink(__DIR__ . '/resources/processed.zip');
$processedFile = __DIR__ . '/resources/processed.zip';
if (file_exists($processedFile)) {
unlink($processedFile);
}

$configTestPath = __DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php';
if (file_exists($configTestPath)) {
unlink(__DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php');
$configTestFile = __DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php';
if (file_exists($configTestFile)) {
unlink($configTestFile);
}

$configTestPathAlt = __DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php';
if (file_exists($configTestPathAlt)) {
unlink(__DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php');
$configTestFileAlt = __DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php';
if (file_exists($configTestFileAlt)) {
unlink($configTestFileAlt);
}

parent::tearDownAfterClass();
Expand Down