diff options
author | hcpp <hcpp@ydb.tech> | 2023-11-08 12:09:41 +0300 |
---|---|---|
committer | hcpp <hcpp@ydb.tech> | 2023-11-08 12:56:14 +0300 |
commit | a361f5b98b98b44ea510d274f6769164640dd5e1 (patch) | |
tree | c47c80962c6e2e7b06798238752fd3da0191a3f6 /library/recipes/tvmtool/examples/ut_with_roles | |
parent | 9478806fde1f4d40bd5a45e7cbe77237dab613e9 (diff) | |
download | ydb-a361f5b98b98b44ea510d274f6769164640dd5e1.tar.gz |
metrics have been added
Diffstat (limited to 'library/recipes/tvmtool/examples/ut_with_roles')
4 files changed, 76 insertions, 0 deletions
diff --git a/library/recipes/tvmtool/examples/ut_with_roles/custom.cfg b/library/recipes/tvmtool/examples/ut_with_roles/custom.cfg new file mode 100644 index 0000000000..8c90b8f62e --- /dev/null +++ b/library/recipes/tvmtool/examples/ut_with_roles/custom.cfg @@ -0,0 +1,10 @@ +{ + "BbEnvType": 1, + "clients": { + "me": { + "secret": "fake_secret", + "self_tvm_id": 42, + "roles_for_idm_slug": "some_slug" + } + } +} diff --git a/library/recipes/tvmtool/examples/ut_with_roles/roles/some_slug.json b/library/recipes/tvmtool/examples/ut_with_roles/roles/some_slug.json new file mode 100644 index 0000000000..15d6ff7e13 --- /dev/null +++ b/library/recipes/tvmtool/examples/ut_with_roles/roles/some_slug.json @@ -0,0 +1,19 @@ +{ + "revision": "foobar", + "born_date": 1642160000, + "tvm": { + "101": { + "/role/service/auth_type/with_user/access_type/write/handlers/routes/": [{}], + "/role/service/auth_type/without_user/access_type/read/handlers/blockedphones/": [{}] + }, + "104": { + "/role/service/auth_type/without_user/access_type/read/handlers/routes/": [{}] + } + }, + "user": { + "1120000000000001": { + "/role/user/access_type/read/handlers/all/": [{}], + "/role/user/access_type/write/handlers/all/": [{}] + } + } +} diff --git a/library/recipes/tvmtool/examples/ut_with_roles/test.py b/library/recipes/tvmtool/examples/ut_with_roles/test.py new file mode 100644 index 0000000000..4a976bc228 --- /dev/null +++ b/library/recipes/tvmtool/examples/ut_with_roles/test.py @@ -0,0 +1,26 @@ +import os +import os.path +import requests + +TVMTOOL_PORT_FILE = "tvmtool.port" +TVMTOOL_AUTHTOKEN_FILE = "tvmtool.authtoken" + + +def _get_tvmtool_params(): + port = int(open(TVMTOOL_PORT_FILE).read()) + authtoken = open(TVMTOOL_AUTHTOKEN_FILE).read() + return port, authtoken + + +def test_tvmtool(): + assert os.path.isfile(TVMTOOL_PORT_FILE) + assert os.path.isfile(TVMTOOL_AUTHTOKEN_FILE) + + port, authtoken = _get_tvmtool_params() + + r = requests.get("http://localhost:%d/tvm/ping" % port) + assert r.text == 'OK' + assert r.status_code == 200 + + r = requests.get("http://localhost:%d/v2/roles?self=me" % port, headers={'Authorization': authtoken}) + assert r.status_code == 200, r.text diff --git a/library/recipes/tvmtool/examples/ut_with_roles/ya.make b/library/recipes/tvmtool/examples/ut_with_roles/ya.make new file mode 100644 index 0000000000..6d658b7318 --- /dev/null +++ b/library/recipes/tvmtool/examples/ut_with_roles/ya.make @@ -0,0 +1,21 @@ +PY3TEST() + +OWNER(g:passport_infra) + +TEST_SRCS( + test.py +) + +PEERDIR( + contrib/python/requests +) + +INCLUDE(${ARCADIA_ROOT}/library/recipes/tvmtool/recipe.inc) + +USE_RECIPE( + library/recipes/tvmtool/tvmtool + library/recipes/tvmtool/examples/ut_with_roles/custom.cfg + --with-roles-dir library/recipes/tvmtool/examples/ut_with_roles/roles +) + +END() |