Skip to content

PHPC-1835: Rotate credentials for Atlas connectivity tests #1220

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 2 commits into from
May 11, 2021
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
Binary file modified .evergreen/atlas-uris.txt.enc
Binary file not shown.
16 changes: 14 additions & 2 deletions tests/atlas.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ if (getenv('TESTS') !== 'tests/atlas.phpt') { echo "skip Atlas tests not wanted\
<?php
$urls = explode("\n", file_get_contents('.evergreen/atlas-uris.txt'));

$isMasterCmd = new \MongoDB\Driver\Command(['isMaster' => 1]);
$command = new \MongoDB\Driver\Command(['ping' => 1]);
$query = new \MongoDB\Driver\Query([]);

foreach ($urls as $url) {
$url = trim($url);

if ($url == '') {
continue;
}

if (strpos($url, '#') === 0) {
echo trim(substr($url, 1)), "\n";
continue;
}

try {
$m = new \MongoDB\Driver\Manager($url);
$m->executeCommand('admin', $isMasterCmd);
$m->executeCommand('admin', $command);
iterator_to_array($m->executeQuery('test.test', $query));
echo "PASS\n";
} catch(Exception $e) {
Expand All @@ -32,16 +38,22 @@ foreach ($urls as $url) {
===DONE===
<?php exit(0); ?>
--EXPECTF--
Atlas replica set (3.4)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the URI file now has the following format:

# Atlas replica set (3.4)
mongodb://user:pass@...
mongodb+srv://user:pass@...

# Atlas sharded cluster (3.4)
mongodb://user:pass@...
mongodb+srv://user:pass@...

# Atlas free tier replica set (4.4)
mongodb://user:pass@...
mongodb+srv://user:pass@...

# Atlas with only TLSv1.1 enabled (3.4)
mongodb://user:pass@...
mongodb+srv://user:pass@...

# Atlas with only TLSv1.2 enabled (3.4)
mongodb://user:pass@...
mongodb+srv://user:pass@...

# Atlas with only TLSv1.2 enabled (3.4) and bad credentials
mongodb://user:INVALID@...
mongodb+srv://user:INVALID@...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That explains the trim you introduced above. Thanks!

PASS
PASS
Atlas sharded cluster (3.4)
PASS
PASS
Atlas free tier replica set (4.4)
PASS
PASS
Atlas with only TLSv1.1 enabled (3.4)
PASS
PASS
Atlas with only TLSv1.2 enabled (3.4)
PASS
PASS
Atlas with only TLSv1.2 enabled (3.4) and bad credentials
FAIL: %s
FAIL: %s
===DONE===