Skip to content

Commit

Permalink
http_proxy: retrieve FolderId from query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
qyryq committed Sep 24, 2024
1 parent 979fcef commit 9d2d2e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ydb/core/http_proxy/http_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ namespace NKikimr::NHttpProxy {
.Counters = nullptr,
.AWSSignature = std::move(HttpContext.GetSignature()),
.IAMToken = HttpContext.IamToken,
.FolderID = ""
.FolderID = HttpContext.FolderId
};

auto authRequestProxy = MakeHolder<NSQS::THttpProxyAuthRequestProxy>(
Expand Down Expand Up @@ -1148,10 +1148,15 @@ namespace NKikimr::NHttpProxy {
SourceAddress = address;
}

DatabasePath = Request->URL;
DatabasePath = Request->URL.Before('?');
if (DatabasePath == "/") {
DatabasePath = "";
}
auto params = TCgiParameters(Request->URL.After('?'));
if (auto it = params.Find("folderId"); it != params.end()) {
FolderId = it->second;
}

//TODO: find out databaseId
ParseHeaders(Request->Headers);
}
Expand Down
14 changes: 14 additions & 0 deletions ydb/core/http_proxy/ut/http_proxy_ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,20 @@ Y_UNIT_TEST_SUITE(TestHttpProxy) {
UNIT_ASSERT_VALUES_EQUAL(resultMessage, "The specified queue doesn't exist.");
}

Y_UNIT_TEST_F(TestGetQueueUrlWithIAM, THttpProxyTestMock) {
auto req = CreateSqsGetQueueUrlRequest();
req["QueueName"] = "not-existing-queue";
auto res = SendHttpRequest("/Root?folderId=XXX", "AmazonSQS.GetQueueUrl", std::move(req), "X-YaCloud-SubjectToken: Bearer proxy_sa@builtin");
UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, 400);

NJson::TJsonValue json;
UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json));
TString resultType = GetByPath<TString>(json, "__type");
UNIT_ASSERT_VALUES_EQUAL(resultType, "AWS.SimpleQueueService.NonExistentQueue");
TString resultMessage = GetByPath<TString>(json, "message");
UNIT_ASSERT_VALUES_EQUAL(resultMessage, "The specified queue doesn't exist.");
}

Y_UNIT_TEST_F(TestSendMessage, THttpProxyTestMock) {
auto createQueueReq = CreateSqsCreateQueueRequest();
auto res = SendHttpRequest("/Root", "AmazonSQS.CreateQueue", std::move(createQueueReq), FormAuthorizationStr("ru-central1"));
Expand Down

0 comments on commit 9d2d2e6

Please sign in to comment.