aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqyryq <qyryq@ydb.tech>2024-09-26 09:11:50 +0300
committerGitHub <noreply@github.com>2024-09-26 09:11:50 +0300
commit9f848dda7aa6a5fbcda6819e82c701a75ddf320f (patch)
tree93270d94cd19cb9a4f10f276a129c0efe1f20601
parent8ebf595f12a02d83fd1e5d52fa6362f9244eb524 (diff)
downloadydb-9f848dda7aa6a5fbcda6819e82c701a75ddf320f.tar.gz
http_proxy: retrieve FolderId from query parameters (#9695)
-rw-r--r--ydb/core/http_proxy/http_req.cpp9
-rw-r--r--ydb/core/http_proxy/ut/http_proxy_ut.h14
2 files changed, 21 insertions, 2 deletions
diff --git a/ydb/core/http_proxy/http_req.cpp b/ydb/core/http_proxy/http_req.cpp
index 8810cc5b53c..d7db194ec8e 100644
--- a/ydb/core/http_proxy/http_req.cpp
+++ b/ydb/core/http_proxy/http_req.cpp
@@ -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>(
@@ -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);
}
diff --git a/ydb/core/http_proxy/ut/http_proxy_ut.h b/ydb/core/http_proxy/ut/http_proxy_ut.h
index aa98767efb7..59c60d4ec0c 100644
--- a/ydb/core/http_proxy/ut/http_proxy_ut.h
+++ b/ydb/core/http_proxy/ut/http_proxy_ut.h
@@ -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"));