Skip to content

Commit 9f848dd

Browse files
authored
http_proxy: retrieve FolderId from query parameters (#9695)
1 parent 8ebf595 commit 9f848dd

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

ydb/core/http_proxy/http_req.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ namespace NKikimr::NHttpProxy {
553553
.Counters = nullptr,
554554
.AWSSignature = std::move(HttpContext.GetSignature()),
555555
.IAMToken = HttpContext.IamToken,
556-
.FolderID = ""
556+
.FolderID = HttpContext.FolderId
557557
};
558558

559559
auto authRequestProxy = MakeHolder<NSQS::THttpProxyAuthRequestProxy>(
@@ -1148,10 +1148,15 @@ namespace NKikimr::NHttpProxy {
11481148
SourceAddress = address;
11491149
}
11501150

1151-
DatabasePath = Request->URL;
1151+
DatabasePath = Request->URL.Before('?');
11521152
if (DatabasePath == "/") {
11531153
DatabasePath = "";
11541154
}
1155+
auto params = TCgiParameters(Request->URL.After('?'));
1156+
if (auto it = params.Find("folderId"); it != params.end()) {
1157+
FolderId = it->second;
1158+
}
1159+
11551160
//TODO: find out databaseId
11561161
ParseHeaders(Request->Headers);
11571162
}

ydb/core/http_proxy/ut/http_proxy_ut.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,20 @@ Y_UNIT_TEST_SUITE(TestHttpProxy) {
16251625
UNIT_ASSERT_VALUES_EQUAL(resultMessage, "The specified queue doesn't exist.");
16261626
}
16271627

1628+
Y_UNIT_TEST_F(TestGetQueueUrlWithIAM, THttpProxyTestMock) {
1629+
auto req = CreateSqsGetQueueUrlRequest();
1630+
req["QueueName"] = "not-existing-queue";
1631+
auto res = SendHttpRequest("/Root?folderId=XXX", "AmazonSQS.GetQueueUrl", std::move(req), "X-YaCloud-SubjectToken: Bearer proxy_sa@builtin");
1632+
UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, 400);
1633+
1634+
NJson::TJsonValue json;
1635+
UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json));
1636+
TString resultType = GetByPath<TString>(json, "__type");
1637+
UNIT_ASSERT_VALUES_EQUAL(resultType, "AWS.SimpleQueueService.NonExistentQueue");
1638+
TString resultMessage = GetByPath<TString>(json, "message");
1639+
UNIT_ASSERT_VALUES_EQUAL(resultMessage, "The specified queue doesn't exist.");
1640+
}
1641+
16281642
Y_UNIT_TEST_F(TestSendMessage, THttpProxyTestMock) {
16291643
auto createQueueReq = CreateSqsCreateQueueRequest();
16301644
auto res = SendHttpRequest("/Root", "AmazonSQS.CreateQueue", std::move(createQueueReq), FormAuthorizationStr("ru-central1"));

0 commit comments

Comments
 (0)