Axivion: Reuse the redirected url for further usage

Do it even when the network reply fails, but contains
the valid json content.

Fixes: QTCREATORBUG-30536
Change-Id: I97f55ccf6997cd2c9ac6be72d673d9cee1a210de
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2024-03-19 14:04:55 +01:00
parent c0a02ecd4e
commit c10b34c1e1

View File

@@ -450,8 +450,10 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
if (error) { if (error) {
if constexpr (std::is_same_v<DtoType, Dto::DashboardInfoDto>) { if constexpr (std::is_same_v<DtoType, Dto::DashboardInfoDto>) {
// Suppress logging error on unauthorized dashboard fetch // Suppress logging error on unauthorized dashboard fetch
if (!dtoStorage->credential && error->type == "UnauthenticatedException") if (!dtoStorage->credential && error->type == "UnauthenticatedException") {
dtoStorage->url = reply->url();
return DoneResult::Success; return DoneResult::Success;
}
} }
errorString = Error(DashboardError(reply->url(), statusCode, errorString = Error(DashboardError(reply->url(), statusCode,
@@ -530,13 +532,11 @@ static void handleCredentialError(const CredentialQuery &credential)
static Group authorizationRecipe() static Group authorizationRecipe()
{ {
const Storage<QUrl> serverUrlStorage;
const Storage<GetDtoStorage<Dto::DashboardInfoDto>> unauthorizedDashboardStorage; const Storage<GetDtoStorage<Dto::DashboardInfoDto>> unauthorizedDashboardStorage;
const auto onUnauthorizedGroupSetup = [unauthorizedDashboardStorage] { const auto onUnauthorizedGroupSetup = [serverUrlStorage, unauthorizedDashboardStorage] {
if (isServerAccessEstablished()) unauthorizedDashboardStorage->url = *serverUrlStorage;
return SetupResult::StopWithSuccess; return isServerAccessEstablished() ? SetupResult::StopWithSuccess : SetupResult::Continue;
unauthorizedDashboardStorage->url = QUrl(settings().server.dashboard);
return SetupResult::Continue;
}; };
const auto onUnauthorizedDashboard = [unauthorizedDashboardStorage] { const auto onUnauthorizedDashboard = [unauthorizedDashboardStorage] {
if (unauthorizedDashboardStorage->dtoData) { if (unauthorizedDashboardStorage->dtoData) {
@@ -575,7 +575,7 @@ static Group authorizationRecipe()
const Storage<QString> passwordStorage; const Storage<QString> passwordStorage;
const Storage<GetDtoStorage<Dto::DashboardInfoDto>> dashboardStorage; const Storage<GetDtoStorage<Dto::DashboardInfoDto>> dashboardStorage;
const auto onPasswordGroupSetup = [passwordStorage, dashboardStorage] { const auto onPasswordGroupSetup = [serverUrlStorage, passwordStorage, dashboardStorage] {
if (dd->m_apiToken) if (dd->m_apiToken)
return SetupResult::StopWithSuccess; return SetupResult::StopWithSuccess;
@@ -589,7 +589,7 @@ static Group authorizationRecipe()
const QString credential = settings().server.username + ':' + *passwordStorage; const QString credential = settings().server.username + ':' + *passwordStorage;
dashboardStorage->credential = "Basic " + credential.toUtf8().toBase64(); dashboardStorage->credential = "Basic " + credential.toUtf8().toBase64();
dashboardStorage->url = QUrl(settings().server.dashboard); dashboardStorage->url = *serverUrlStorage;
return SetupResult::Continue; return SetupResult::Continue;
}; };
@@ -632,13 +632,13 @@ static Group authorizationRecipe()
return DoneResult::Success; return DoneResult::Success;
}; };
const auto onDashboardGroupSetup = [dashboardStorage] { const auto onDashboardGroupSetup = [serverUrlStorage, dashboardStorage] {
if (dd->m_dashboardInfo || dd->m_serverAccess != ServerAccess::WithAuthorization if (dd->m_dashboardInfo || dd->m_serverAccess != ServerAccess::WithAuthorization
|| !dd->m_apiToken) { || !dd->m_apiToken) {
return SetupResult::StopWithSuccess; // Unauthorized access should have collect dashboard before return SetupResult::StopWithSuccess; // Unauthorized access should have collect dashboard before
} }
dashboardStorage->credential = "AxToken " + *dd->m_apiToken; dashboardStorage->credential = "AxToken " + *dd->m_apiToken;
dashboardStorage->url = QUrl(settings().server.dashboard); dashboardStorage->url = *serverUrlStorage;
return SetupResult::Continue; return SetupResult::Continue;
}; };
const auto onDeleteCredentialSetup = [dashboardStorage](CredentialQuery &credential) { const auto onDeleteCredentialSetup = [dashboardStorage](CredentialQuery &credential) {
@@ -656,11 +656,16 @@ static Group authorizationRecipe()
}; };
return { return {
serverUrlStorage,
onGroupSetup([serverUrlStorage] { *serverUrlStorage = QUrl(settings().server.dashboard); }),
Group { Group {
unauthorizedDashboardStorage, unauthorizedDashboardStorage,
onGroupSetup(onUnauthorizedGroupSetup), onGroupSetup(onUnauthorizedGroupSetup),
dtoRecipe(unauthorizedDashboardStorage), dtoRecipe(unauthorizedDashboardStorage),
Sync(onUnauthorizedDashboard) Sync(onUnauthorizedDashboard),
onGroupDone([serverUrlStorage, unauthorizedDashboardStorage] {
*serverUrlStorage = unauthorizedDashboardStorage->url;
}),
}, },
Group { Group {
LoopUntil(onCredentialLoopCondition), LoopUntil(onCredentialLoopCondition),