Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php
index 5af731d81f..ec4bad34a2 100644
--- a/src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php
+++ b/src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php
@@ -1,72 +1,102 @@
<?php
final class HarbormasterHTTPRequestBuildStepImplementation
extends HarbormasterBuildStepImplementation {
public function getName() {
return pht('Make HTTP Request');
}
public function getGenericDescription() {
return pht('Make an HTTP request.');
}
public function getDescription() {
$domain = null;
$uri = $this->getSetting('uri');
if ($uri) {
$domain = id(new PhutilURI($uri))->getDomain();
}
- return pht(
- 'Make an HTTP %s request to %s.',
- $this->formatSettingForDescription('method', 'POST'),
- $this->formatValueForDescription($domain));
+ $method = $this->formatSettingForDescription('method', 'POST');
+ $domain = $this->formatValueForDescription($domain);
+
+ if ($this->getSetting('credential')) {
+ return pht(
+ 'Make an authenticated HTTP %s request to %s.',
+ $method,
+ $domain);
+ } else {
+ return pht(
+ 'Make an HTTP %s request to %s.',
+ $method,
+ $domain);
+ }
}
public function execute(
HarbormasterBuild $build,
HarbormasterBuildTarget $build_target) {
+ $viewer = PhabricatorUser::getOmnipotentUser();
$settings = $this->getSettings();
$variables = $build_target->getVariables();
$uri = $this->mergeVariables(
'vurisprintf',
$settings['uri'],
$variables);
$log_body = $build->createLog($build_target, $uri, 'http-body');
$start = $log_body->start();
$method = nonempty(idx($settings, 'method'), 'POST');
- list($status, $body, $headers) = id(new HTTPSFuture($uri))
+ $future = id(new HTTPSFuture($uri))
->setMethod($method)
- ->setTimeout(60)
- ->resolve();
+ ->setTimeout(60);
+
+ $credential_phid = $this->getSetting('credential');
+ if ($credential_phid) {
+ $key = PassphrasePasswordKey::loadFromPHID(
+ $credential_phid,
+ $viewer);
+ $future->setHTTPBasicAuthCredentials(
+ $key->getUsernameEnvelope()->openEnvelope(),
+ $key->getPasswordEnvelope());
+ }
+
+ list($status, $body, $headers) = $future->resolve();
$log_body->append($body);
$log_body->finalize($start);
if ($status->getStatusCode() != 200) {
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
}
}
public function getFieldSpecifications() {
return array(
'uri' => array(
'name' => pht('URI'),
'type' => 'text',
'required' => true,
),
'method' => array(
'name' => pht('HTTP Method'),
'type' => 'select',
'options' => array_fuse(array('POST', 'GET', 'PUT', 'DELETE')),
),
+ 'credential' => array(
+ 'name' => pht('Credentials'),
+ 'type' => 'credential',
+ 'credential.type'
+ => PassphraseCredentialTypePassword::CREDENTIAL_TYPE,
+ 'credential.provides'
+ => PassphraseCredentialTypePassword::PROVIDES_TYPE,
+ ),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jul 28, 2:30 AM (1 w, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
186368
Default Alt Text
(3 KB)

Event Timeline