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
17 changes: 16 additions & 1 deletion app/Console/Commands/MigrateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ public function handle()
include $cdash_app_dir . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
include $cdash_app_dir . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'version.php';
foreach (get_defined_vars() as $key => $value) {

if ($key == 'OAUTH2_PROVIDERS') {
foreach ($value as $k => $v) {
$provider = strtoupper($k);
if (array_key_exists('clientId', $v)) {
$config["{$provider}_CLIENT_ID"] = $v['clientId'];
}
if (array_key_exists('clientSecret', $v)) {
$config["{$provider}_CLIENT_SECRET"] = $v['clientSecret'];
}
if (array_key_exists('domain', $v)) {
$config["{$provider}_DOMAIN"] = $v['domain'];
}
}
}

if (strpos($key, 'CDASH_') !== 0) {
continue;
}
Expand Down Expand Up @@ -154,7 +170,6 @@ public function handle()
}

/* still TODO for special handling:
* oauth2 stuff
* associative arrays that will need code-level changes:
MEMCACHE_SERVER, GOOGLE_MAP_API_KEY
*/
Expand Down
19 changes: 19 additions & 0 deletions tests/Feature/MigrateConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ public function testMigrateConfigCommand()
$CDASH_BASE_URL = 'http://localhost/CDash';
$CDASH_LOG_LEVEL = LOG_DEBUG;
$CDASH_UNLIMITED_PROJECTS = ['Project1', 'Project2'];
$OAUTH2_PROVIDERS['GitHub'] = [
'clientId' => 'github_client_id',
'clientSecret' => 'github_client_secret'
];
$OAUTH2_PROVIDERS['GitLab'] = [
'clientId' => 'gitlab_client_id',
'clientSecret' => 'gitlab_client_secret',
'domain' => 'https://gitlab.kitware.com'
];
$OAUTH2_PROVIDERS['Google'] = [
'clientId' => 'google_client_id',
'clientSecret' => 'google_client_secret'
];
EOT;
file_put_contents($this->config_file, $config_contents);

Expand All @@ -64,6 +77,12 @@ public function testMigrateConfigCommand()
$this->assertContains('APP_TIMEZONE=America/New_York', $actual);
$this->assertContains('APP_LOG_LEVEL=debug', $actual);
$this->assertContains('UNLIMITED_PROJECTS=["Project1","Project2"]', $actual);
$this->assertContains('GITHUB_CLIENT_SECRET=github_client_secret', $actual);
$this->assertContains('GITLAB_CLIENT_ID=gitlab_client_id', $actual);
$this->assertContains('GITLAB_CLIENT_SECRET=gitlab_client_secret', $actual);
$this->assertContains('GITLAB_DOMAIN=https://gitlab.kitware.com', $actual);
$this->assertContains('GOOGLE_CLIENT_ID=google_client_id', $actual);
$this->assertContains('GOOGLE_CLIENT_SECRET=google_client_secret', $actual);

// Default value (mysql) does not get written to .env.
$this->assertNotContains('DB_CONNECTION=', $actual);
Expand Down