Repository navigation
Pull in the default SSL config for DB backup/restore commands #19366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1f85ec
Pull in the default SSL config settings
brandonkelly fcc390f
Check for PDO::MYSQL_ATTR_SSL_CAPATH and MYSQL_ATTR_SSL_CIPHER
brandonkelly a9922dc
Make sure the attributes exist
brandonkelly 74b3915
Fix Windows compatibility
brandonkelly 4005938
Ignore redacted values
brandonkelly eaec9ca
Merge branch '5.x' into feature/default-ssl-conf
brandonkelly 432d257
Merge remote-tracking branch 'origin/5.12' into feature/default-ssl-conf
brandonkelly 927cbba
Carry over all SSL/TLS defaults for the program being run
brandonkelly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| <?php | ||
| /** | ||
| * @link https://craftcms.com/ | ||
| * @copyright Copyright (c) Pixel & Tonic, Inc. | ||
| * @license https://craftcms.github.io/license/ | ||
| */ | ||
|
|
||
| namespace crafttests\unit\db\mysql; | ||
|
|
||
| use Craft; | ||
| use craft\db\mysql\Schema; | ||
| use craft\test\TestCase; | ||
|
|
||
| /** | ||
| * Unit tests for the MySQL Schema class. | ||
| * | ||
| * @author Pixel & Tonic, Inc. <support@pixelandtonic.com> | ||
| * @since 5.12.0 | ||
| */ | ||
| class SchemaTest extends TestCase | ||
| { | ||
| /** | ||
| * @dataProvider sslDirectivesFromPrintDefaultsDataProvider | ||
| * @param string $expected | ||
| * @param string $output | ||
| */ | ||
| public function testSslDirectivesFromPrintDefaults(string $expected, string $output): void | ||
| { | ||
| $schema = Craft::$app->getDb()->getSchema(); | ||
| if (!$schema instanceof Schema) { | ||
| $this->markTestSkipped('The test database isn’t MySQL.'); | ||
| } | ||
|
|
||
| self::assertSame($expected, $this->invokeMethod($schema, '_sslDirectivesFromPrintDefaults', [$output])); | ||
| } | ||
|
|
||
| public static function sslDirectivesFromPrintDefaultsDataProvider(): array | ||
| { | ||
| $header = 'mysqldump would have been started with the following arguments:' . PHP_EOL; | ||
| $nl = PHP_EOL; | ||
|
|
||
| return [ | ||
| 'empty' => ['', ''], | ||
| 'header only' => ['', $header], | ||
| 'no ssl options' => ['', $header . '--host=localhost --user=root --password=***** --quick'], | ||
| 'basic' => [ | ||
| "{$nl}ssl-ca=/etc/ssl/ca.pem{$nl}ssl-cert=/etc/ssl/cert.pem{$nl}ssl-key=/etc/ssl/key.pem", | ||
| $header . '--host=db --ssl-ca=/etc/ssl/ca.pem --ssl-cert=/etc/ssl/cert.pem --ssl-key=/etc/ssl/key.pem --quick', | ||
| ], | ||
| 'flags and prefixes' => [ | ||
| "{$nl}skip-ssl{$nl}disable-ssl-verify-server-cert{$nl}loose-ssl-mode=REQUIRED{$nl}ssl=0", | ||
| $header . '--skip-ssl --disable-ssl-verify-server-cert --loose-ssl-mode=REQUIRED --ssl=0', | ||
| ], | ||
| 'verification and tls' => [ | ||
| "{$nl}skip-ssl=true{$nl}ssl-verify-server-cert=0{$nl}tls-version=TLSv1.2,TLSv1.3", | ||
| $header . '--skip-ssl=true --ssl-verify-server-cert=0 --tls-version=TLSv1.2,TLSv1.3', | ||
| ], | ||
| 'underscores' => [ | ||
| "{$nl}ssl-ca=/etc/ssl/ca.pem", | ||
| $header . '--ssl_ca=/etc/ssl/ca.pem', | ||
| ], | ||
| 'spaces in values' => [ | ||
| "{$nl}ssl-ca=/path/with spaces/ca.pem{$nl}ssl-key=/other path/key.pem", | ||
| $header . '--ssl-ca=/path/with spaces/ca.pem --quick --ssl-key=/other path/key.pem', | ||
| ], | ||
| 'windows paths' => [ | ||
| "{$nl}ssl-ca=C:\\\\Program Files\\\\MySQL\\\\ca.pem", | ||
| $header . '--ssl-ca=C:\\Program Files\\MySQL\\ca.pem', | ||
| ], | ||
| 'quoted values' => [ | ||
| "{$nl}ssl-cipher=AES256-SHA", | ||
| $header . '--ssl-cipher="AES256-SHA"', | ||
| ], | ||
| 'redacted values' => ['', $header . '--ssl-key=*****'], | ||
| 'not ssl' => ['', $header . '--sslx=1 --skip-sslx --tlsfoo=bar'], | ||
| ]; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.