Skip to content

Commit f267d5f

Browse files
committed
5124: Updated test command
1 parent c3e2ad4 commit f267d5f

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

web/profiles/custom/os2loop/modules/os2loop_cura_login/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ drush os2loop-cura-login:get-login-url --help
3838
```
3939

4040
``` shell name=drush-get-login-url
41-
drush --uri='http://nginx:8080' os2loop-cura-login:get-login-url [email protected] \
42-
--algorithm=$(drush config:get --format string os2loop_cura_login.settings cura.signing_algorithm --include-overridden) \
43-
--secret=$(drush config:get --format string os2loop_cura_login.settings cura.signing_secret --include-overridden)
41+
drush os2loop-cura-login:get-login-url [email protected] --get=jwt --destination=/user \
42+
--algorithm="$(drush config:get --format string os2loop_cura_login.settings cura.signing_algorithm --include-overridden)" \
43+
--secret="$(drush config:get --format string os2loop_cura_login.settings cura.signing_secret --include-overridden)"
4444
```
4545

4646
## Development and debugging

web/profiles/custom/os2loop/modules/os2loop_cura_login/src/Drush/Commands/Os2loopCuraLoginCommands.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function getLoginUrl(
4242
'get' => NULL,
4343
'secret' => NULL,
4444
'algorithm' => 'HS256',
45+
'destination' => NULL,
4546
],
4647
) {
4748
// https://github.com/firebase/php-jwt?tab=readme-ov-file#example
@@ -56,6 +57,9 @@ public function getLoginUrl(
5657

5758
$routeName = 'os2loop_cura_login.start';
5859
$routeParameters = [];
60+
if ($destination = trim($options['destination'])) {
61+
$routeParameters['destination'] = $destination;
62+
}
5963
$requestOptions = [];
6064
if ($name = $options['get']) {
6165
$method = Request::METHOD_GET;
@@ -69,17 +73,23 @@ public function getLoginUrl(
6973
$requestOptions['form_params'] = ['payload' => $jwt];
7074
}
7175
$url = Url::fromRoute($routeName, $routeParameters)->setAbsolute()->toString(TRUE)->getGeneratedUrl();
72-
$this->io()->writeln($method === Request::METHOD_POST
73-
? sprintf('POST\'ing to %s', $url)
74-
: sprintf('GET\'ing %s', $url),
75-
);
76-
$response = $this->httpClient->request($method, $url, $requestOptions);
7776

78-
$this->io()->writeln(Yaml::encode([
79-
'status' => $response->getStatusCode(),
80-
'headers' => Yaml::encode($response->getHeaders()),
81-
'body' => $response->getBody()->getContents(),
82-
]));
77+
if ($method === Request::METHOD_GET) {
78+
$this->io()->writeln($url);
79+
}
80+
else {
81+
$this->io()->writeln(sprintf('POST\'ing to %s', $url));
82+
$response = $this->httpClient->request($method, $url, $requestOptions);
83+
84+
$contents = $response->getBody()->getContents();
85+
$this->io()->writeln(Yaml::encode([
86+
'status' => $response->getStatusCode(),
87+
'headers' => Yaml::encode($response->getHeaders()),
88+
'contents' => $contents,
89+
]));
90+
91+
$this->io()->writeln($contents);
92+
}
8393
}
8494

8595
}

0 commit comments

Comments
 (0)