1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Rename PassphraseCredentialType subclasses for consistency

Summary: Ref T5655.

Test Plan: `arc unit` + `grep`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D13266
This commit is contained in:
Joshua Spence 2015-06-14 14:11:55 +10:00
parent addcef962b
commit ea7397f7e4
16 changed files with 42 additions and 41 deletions

View file

@ -26,7 +26,7 @@ foreach (new LiskMigrationIterator($table) as $repository) {
if ($proto == 'http' || $proto == 'https' || $proto == 'svn') { if ($proto == 'http' || $proto == 'https' || $proto == 'svn') {
$username = $repository->getDetail('http-login'); $username = $repository->getDetail('http-login');
$secret = $repository->getDetail('http-pass'); $secret = $repository->getDetail('http-pass');
$type = PassphraseCredentialTypePassword::CREDENTIAL_TYPE; $type = PassphrasePasswordCredentialType::CREDENTIAL_TYPE;
} else { } else {
$username = $repository->getDetail('ssh-login'); $username = $repository->getDetail('ssh-login');
if (!$username) { if (!$username) {
@ -42,10 +42,10 @@ foreach (new LiskMigrationIterator($table) as $repository) {
$file = $repository->getDetail('ssh-keyfile'); $file = $repository->getDetail('ssh-keyfile');
if ($file) { if ($file) {
$secret = $file; $secret = $file;
$type = PassphraseCredentialTypeSSHPrivateKeyFile::CREDENTIAL_TYPE; $type = PassphraseSSHPrivateKeyFileCredentialType::CREDENTIAL_TYPE;
} else { } else {
$secret = $repository->getDetail('ssh-key'); $secret = $repository->getDetail('ssh-key');
$type = PassphraseCredentialTypeSSHPrivateKeyText::CREDENTIAL_TYPE; $type = PassphraseSSHPrivateKeyTextCredentialType::CREDENTIAL_TYPE;
} }
} }

View file

@ -1260,17 +1260,17 @@ phutil_register_library_map(array(
'PassphraseCredentialTransactionEditor' => 'applications/passphrase/editor/PassphraseCredentialTransactionEditor.php', 'PassphraseCredentialTransactionEditor' => 'applications/passphrase/editor/PassphraseCredentialTransactionEditor.php',
'PassphraseCredentialTransactionQuery' => 'applications/passphrase/query/PassphraseCredentialTransactionQuery.php', 'PassphraseCredentialTransactionQuery' => 'applications/passphrase/query/PassphraseCredentialTransactionQuery.php',
'PassphraseCredentialType' => 'applications/passphrase/credentialtype/PassphraseCredentialType.php', 'PassphraseCredentialType' => 'applications/passphrase/credentialtype/PassphraseCredentialType.php',
'PassphraseCredentialTypePassword' => 'applications/passphrase/credentialtype/PassphraseCredentialTypePassword.php',
'PassphraseCredentialTypeSSHGeneratedKey' => 'applications/passphrase/credentialtype/PassphraseCredentialTypeSSHGeneratedKey.php',
'PassphraseCredentialTypeSSHPrivateKey' => 'applications/passphrase/credentialtype/PassphraseCredentialTypeSSHPrivateKey.php',
'PassphraseCredentialTypeSSHPrivateKeyFile' => 'applications/passphrase/credentialtype/PassphraseCredentialTypeSSHPrivateKeyFile.php',
'PassphraseCredentialTypeSSHPrivateKeyText' => 'applications/passphrase/credentialtype/PassphraseCredentialTypeSSHPrivateKeyText.php',
'PassphraseCredentialViewController' => 'applications/passphrase/controller/PassphraseCredentialViewController.php', 'PassphraseCredentialViewController' => 'applications/passphrase/controller/PassphraseCredentialViewController.php',
'PassphraseDAO' => 'applications/passphrase/storage/PassphraseDAO.php', 'PassphraseDAO' => 'applications/passphrase/storage/PassphraseDAO.php',
'PassphrasePasswordCredentialType' => 'applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php',
'PassphrasePasswordKey' => 'applications/passphrase/keys/PassphrasePasswordKey.php', 'PassphrasePasswordKey' => 'applications/passphrase/keys/PassphrasePasswordKey.php',
'PassphraseQueryConduitAPIMethod' => 'applications/passphrase/conduit/PassphraseQueryConduitAPIMethod.php', 'PassphraseQueryConduitAPIMethod' => 'applications/passphrase/conduit/PassphraseQueryConduitAPIMethod.php',
'PassphraseRemarkupRule' => 'applications/passphrase/remarkup/PassphraseRemarkupRule.php', 'PassphraseRemarkupRule' => 'applications/passphrase/remarkup/PassphraseRemarkupRule.php',
'PassphraseSSHGeneratedKeyCredentialType' => 'applications/passphrase/credentialtype/PassphraseSSHGeneratedKeyCredentialType.php',
'PassphraseSSHKey' => 'applications/passphrase/keys/PassphraseSSHKey.php', 'PassphraseSSHKey' => 'applications/passphrase/keys/PassphraseSSHKey.php',
'PassphraseSSHPrivateKeyCredentialType' => 'applications/passphrase/credentialtype/PassphraseSSHPrivateKeyCredentialType.php',
'PassphraseSSHPrivateKeyFileCredentialType' => 'applications/passphrase/credentialtype/PassphraseSSHPrivateKeyFileCredentialType.php',
'PassphraseSSHPrivateKeyTextCredentialType' => 'applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php',
'PassphraseSchemaSpec' => 'applications/passphrase/storage/PassphraseSchemaSpec.php', 'PassphraseSchemaSpec' => 'applications/passphrase/storage/PassphraseSchemaSpec.php',
'PassphraseSearchIndexer' => 'applications/passphrase/search/PassphraseSearchIndexer.php', 'PassphraseSearchIndexer' => 'applications/passphrase/search/PassphraseSearchIndexer.php',
'PassphraseSecret' => 'applications/passphrase/storage/PassphraseSecret.php', 'PassphraseSecret' => 'applications/passphrase/storage/PassphraseSecret.php',
@ -3933,6 +3933,7 @@ phutil_register_library_map(array(
'DivinerDAO', 'DivinerDAO',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
), ),
'DivinerLivePublisher' => 'DivinerPublisher', 'DivinerLivePublisher' => 'DivinerPublisher',
'DivinerLiveSymbol' => array( 'DivinerLiveSymbol' => array(
@ -4641,17 +4642,17 @@ phutil_register_library_map(array(
'PassphraseCredentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'PassphraseCredentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'PassphraseCredentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PassphraseCredentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PassphraseCredentialType' => 'Phobject', 'PassphraseCredentialType' => 'Phobject',
'PassphraseCredentialTypePassword' => 'PassphraseCredentialType',
'PassphraseCredentialTypeSSHGeneratedKey' => 'PassphraseCredentialTypeSSHPrivateKey',
'PassphraseCredentialTypeSSHPrivateKey' => 'PassphraseCredentialType',
'PassphraseCredentialTypeSSHPrivateKeyFile' => 'PassphraseCredentialTypeSSHPrivateKey',
'PassphraseCredentialTypeSSHPrivateKeyText' => 'PassphraseCredentialTypeSSHPrivateKey',
'PassphraseCredentialViewController' => 'PassphraseController', 'PassphraseCredentialViewController' => 'PassphraseController',
'PassphraseDAO' => 'PhabricatorLiskDAO', 'PassphraseDAO' => 'PhabricatorLiskDAO',
'PassphrasePasswordCredentialType' => 'PassphraseCredentialType',
'PassphrasePasswordKey' => 'PassphraseAbstractKey', 'PassphrasePasswordKey' => 'PassphraseAbstractKey',
'PassphraseQueryConduitAPIMethod' => 'PassphraseConduitAPIMethod', 'PassphraseQueryConduitAPIMethod' => 'PassphraseConduitAPIMethod',
'PassphraseRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PassphraseRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PassphraseSSHGeneratedKeyCredentialType' => 'PassphraseSSHPrivateKeyCredentialType',
'PassphraseSSHKey' => 'PassphraseAbstractKey', 'PassphraseSSHKey' => 'PassphraseAbstractKey',
'PassphraseSSHPrivateKeyCredentialType' => 'PassphraseCredentialType',
'PassphraseSSHPrivateKeyFileCredentialType' => 'PassphraseSSHPrivateKeyCredentialType',
'PassphraseSSHPrivateKeyTextCredentialType' => 'PassphraseSSHPrivateKeyCredentialType',
'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PassphraseSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PassphraseSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PassphraseSecret' => 'PassphraseDAO', 'PassphraseSecret' => 'PassphraseDAO',

View file

@ -591,8 +591,8 @@ final class DiffusionRepositoryCreateController
if ($this->isSSHProtocol($proto)) { if ($this->isSSHProtocol($proto)) {
$c_credential->setLabel(pht('SSH Key')); $c_credential->setLabel(pht('SSH Key'));
$c_credential->setCredentialType( $c_credential->setCredentialType(
PassphraseCredentialTypeSSHPrivateKeyText::CREDENTIAL_TYPE); PassphraseSSHPrivateKeyTextCredentialType::CREDENTIAL_TYPE);
$provides_type = PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE; $provides_type = PassphraseSSHPrivateKeyCredentialType::PROVIDES_TYPE;
$page->addRemarkupInstructions( $page->addRemarkupInstructions(
pht( pht(
@ -607,8 +607,8 @@ final class DiffusionRepositoryCreateController
$c_credential->setLabel(pht('Password')); $c_credential->setLabel(pht('Password'));
$c_credential->setAllowNull(true); $c_credential->setAllowNull(true);
$c_credential->setCredentialType( $c_credential->setCredentialType(
PassphraseCredentialTypePassword::CREDENTIAL_TYPE); PassphrasePasswordCredentialType::CREDENTIAL_TYPE);
$provides_type = PassphraseCredentialTypePassword::PROVIDES_TYPE; $provides_type = PassphrasePasswordCredentialType::PROVIDES_TYPE;
$page->addRemarkupInstructions( $page->addRemarkupInstructions(
pht( pht(
@ -663,7 +663,7 @@ final class DiffusionRepositoryCreateController
pht('You must choose an SSH credential to connect over SSH.')); pht('You must choose an SSH credential to connect over SSH.'));
} }
$ssh_type = PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE; $ssh_type = PassphraseSSHPrivateKeyCredentialType::PROVIDES_TYPE;
if ($credential->getProvidesType() !== $ssh_type) { if ($credential->getProvidesType() !== $ssh_type) {
$c_credential->setError(pht('Invalid')); $c_credential->setError(pht('Invalid'));
$page->addPageError( $page->addPageError(
@ -674,7 +674,7 @@ final class DiffusionRepositoryCreateController
} else if ($this->isUsernamePasswordProtocol($proto)) { } else if ($this->isUsernamePasswordProtocol($proto)) {
if ($credential) { if ($credential) {
$password_type = PassphraseCredentialTypePassword::PROVIDES_TYPE; $password_type = PassphrasePasswordCredentialType::PROVIDES_TYPE;
if ($credential->getProvidesType() !== $password_type) { if ($credential->getProvidesType() !== $password_type) {
$c_credential->setError(pht('Invalid')); $c_credential->setError(pht('Invalid'));
$page->addPageError( $page->addPageError(

View file

@ -24,7 +24,7 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
} }
if ($credential->getProvidesType() !== if ($credential->getProvidesType() !==
PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE) { PassphraseSSHPrivateKeyCredentialType::PROVIDES_TYPE) {
throw new Exception(pht('Only private key credentials are supported.')); throw new Exception(pht('Only private key credentials are supported.'));
} }

View file

@ -16,7 +16,7 @@ final class DrydockSFTPFilesystemInterface extends DrydockFilesystemInterface {
->executeOne(); ->executeOne();
if ($credential->getProvidesType() !== if ($credential->getProvidesType() !==
PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE) { PassphraseSSHPrivateKeyCredentialType::PROVIDES_TYPE) {
throw new Exception(pht('Only private key credentials are supported.')); throw new Exception(pht('Only private key credentials are supported.'));
} }

View file

@ -95,9 +95,9 @@ final class HarbormasterHTTPRequestBuildStepImplementation
'name' => pht('Credentials'), 'name' => pht('Credentials'),
'type' => 'credential', 'type' => 'credential',
'credential.type' 'credential.type'
=> PassphraseCredentialTypePassword::CREDENTIAL_TYPE, => PassphrasePasswordCredentialType::CREDENTIAL_TYPE,
'credential.provides' 'credential.provides'
=> PassphraseCredentialTypePassword::PROVIDES_TYPE, => PassphrasePasswordCredentialType::PROVIDES_TYPE,
), ),
); );
} }

View file

@ -78,7 +78,7 @@ final class PassphraseQueryConduitAPIMethod
} }
switch ($credential->getCredentialType()) { switch ($credential->getCredentialType()) {
case PassphraseCredentialTypeSSHPrivateKeyFile::CREDENTIAL_TYPE: case PassphraseSSHPrivateKeyFileCredentialType::CREDENTIAL_TYPE:
if ($secret) { if ($secret) {
$material['file'] = $secret; $material['file'] = $secret;
} }
@ -86,8 +86,8 @@ final class PassphraseQueryConduitAPIMethod
$material['publicKey'] = $public_key; $material['publicKey'] = $public_key;
} }
break; break;
case PassphraseCredentialTypeSSHGeneratedKey::CREDENTIAL_TYPE: case PassphraseSSHGeneratedKeyCredentialType::CREDENTIAL_TYPE:
case PassphraseCredentialTypeSSHPrivateKeyText::CREDENTIAL_TYPE: case PassphraseSSHPrivateKeyTextCredentialType::CREDENTIAL_TYPE:
if ($secret) { if ($secret) {
$material['privateKey'] = $secret; $material['privateKey'] = $secret;
} }
@ -95,7 +95,7 @@ final class PassphraseQueryConduitAPIMethod
$material['publicKey'] = $public_key; $material['publicKey'] = $public_key;
} }
break; break;
case PassphraseCredentialTypePassword::CREDENTIAL_TYPE: case PassphrasePasswordCredentialType::CREDENTIAL_TYPE:
if ($secret) { if ($secret) {
$material['password'] = $secret; $material['password'] = $secret;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
final class PassphraseCredentialTypePassword final class PassphrasePasswordCredentialType
extends PassphraseCredentialType { extends PassphraseCredentialType {
const CREDENTIAL_TYPE = 'password'; const CREDENTIAL_TYPE = 'password';

View file

@ -1,7 +1,7 @@
<?php <?php
final class PassphraseCredentialTypeSSHGeneratedKey final class PassphraseSSHGeneratedKeyCredentialType
extends PassphraseCredentialTypeSSHPrivateKey { extends PassphraseSSHPrivateKeyCredentialType {
const CREDENTIAL_TYPE = 'ssh-generated-key'; const CREDENTIAL_TYPE = 'ssh-generated-key';

View file

@ -1,6 +1,6 @@
<?php <?php
abstract class PassphraseCredentialTypeSSHPrivateKey abstract class PassphraseSSHPrivateKeyCredentialType
extends PassphraseCredentialType { extends PassphraseCredentialType {
const PROVIDES_TYPE = 'provides/ssh-key-file'; const PROVIDES_TYPE = 'provides/ssh-key-file';

View file

@ -1,7 +1,7 @@
<?php <?php
final class PassphraseCredentialTypeSSHPrivateKeyFile final class PassphraseSSHPrivateKeyFileCredentialType
extends PassphraseCredentialTypeSSHPrivateKey { extends PassphraseSSHPrivateKeyCredentialType {
const CREDENTIAL_TYPE = 'ssh-key-file'; const CREDENTIAL_TYPE = 'ssh-key-file';

View file

@ -1,7 +1,7 @@
<?php <?php
final class PassphraseCredentialTypeSSHPrivateKeyText final class PassphraseSSHPrivateKeyTextCredentialType
extends PassphraseCredentialTypeSSHPrivateKey { extends PassphraseSSHPrivateKeyCredentialType {
const CREDENTIAL_TYPE = 'ssh-key-text'; const CREDENTIAL_TYPE = 'ssh-key-text';

View file

@ -7,7 +7,7 @@ final class PassphrasePasswordKey extends PassphraseAbstractKey {
return $key->loadAndValidateFromPHID( return $key->loadAndValidateFromPHID(
$phid, $phid,
$viewer, $viewer,
PassphraseCredentialTypePassword::PROVIDES_TYPE); PassphrasePasswordCredentialType::PROVIDES_TYPE);
} }
public function getPasswordEnvelope() { public function getPasswordEnvelope() {

View file

@ -9,13 +9,13 @@ final class PassphraseSSHKey extends PassphraseAbstractKey {
return $key->loadAndValidateFromPHID( return $key->loadAndValidateFromPHID(
$phid, $phid,
$viewer, $viewer,
PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE); PassphraseSSHPrivateKeyCredentialType::PROVIDES_TYPE);
} }
public function getKeyfileEnvelope() { public function getKeyfileEnvelope() {
$credential = $this->requireCredential(); $credential = $this->requireCredential();
$file_type = PassphraseCredentialTypeSSHPrivateKeyFile::CREDENTIAL_TYPE; $file_type = PassphraseSSHPrivateKeyFileCredentialType::CREDENTIAL_TYPE;
if ($credential->getCredentialType() != $file_type) { if ($credential->getCredentialType() != $file_type) {
// If the credential does not store a file, write the key text out to a // If the credential does not store a file, write the key text out to a
// temporary file so we can pass it to `ssh`. // temporary file so we can pass it to `ssh`.

View file

@ -19,8 +19,8 @@ final class PhabricatorRepositoryURITestCase
$http_secret = id(new PassphraseSecret())->setSecretData('quack')->save(); $http_secret = id(new PassphraseSecret())->setSecretData('quack')->save();
$http_credential = PassphraseCredential::initializeNewCredential($user) $http_credential = PassphraseCredential::initializeNewCredential($user)
->setCredentialType(PassphraseCredentialTypePassword::CREDENTIAL_TYPE) ->setCredentialType(PassphrasePasswordCredentialType::CREDENTIAL_TYPE)
->setProvidesType(PassphraseCredentialTypePassword::PROVIDES_TYPE) ->setProvidesType(PassphrasePasswordCredentialType::PROVIDES_TYPE)
->setUsername('duck') ->setUsername('duck')
->setSecretID($http_secret->getID()) ->setSecretID($http_secret->getID())
->save(); ->save();

View file

@ -24,7 +24,7 @@ final class PhabricatorStandardCustomFieldCredential
$all_types = PassphraseCredentialType::getAllProvidesTypes(); $all_types = PassphraseCredentialType::getAllProvidesTypes();
if (!in_array($provides_type, $all_types)) { if (!in_array($provides_type, $all_types)) {
$provides_type = PassphraseCredentialTypePassword::PROVIDES_TYPE; $provides_type = PassphrasePasswordCredentialType::PROVIDES_TYPE;
} }
$credentials = id(new PassphraseCredentialQuery()) $credentials = id(new PassphraseCredentialQuery())