From caa3f62a657c6d75c0f515a089edcfb06148e5be Mon Sep 17 00:00:00 2001 From: Sergey Yakubov <sergey.yakubov@desy.de> Date: Wed, 28 Apr 2021 13:48:53 +0200 Subject: [PATCH] fix authorization for auto beamtime --- .../src/asapo_authorizer/server/authorize.go | 14 ++++++-- .../asapo_authorizer/server/authorize_test.go | 21 +++++------ .../src/asapo_authorizer/server/server.go | 2 +- .../asapo/configs/asapo-authorizer.json | 6 ++-- .../scripts/authorizer.json.tpl | 6 ++-- .../request_handler_authorize.cpp | 12 +++---- .../request_handler_authorize.h | 2 +- .../test_request_handler_authorizer.cpp | 4 +-- .../authorizer/check_authorize/CMakeLists.txt | 1 + .../beamtime-metadata-11111111.json | 2 +- .../beamtime-metadata-11111112.json | 36 +++++++++++++++++++ .../authorizer/check_authorize/check_linux.sh | 7 +++- .../check_authorize/check_windows.bat | 2 +- .../beamtime-metadata-11111111.json | 2 +- .../aai/beamtime-metadata-11111111.json | 2 +- tests/automatic/producer/aai/producer_aai.py | 4 +-- .../settings/authorizer_settings.json.tpl.lin | 6 ++-- .../settings/authorizer_settings.json.tpl.win | 6 ++-- 18 files changed, 92 insertions(+), 43 deletions(-) create mode 100644 tests/automatic/authorizer/check_authorize/beamtime-metadata-11111112.json diff --git a/authorizer/src/asapo_authorizer/server/authorize.go b/authorizer/src/asapo_authorizer/server/authorize.go index a70f03439..b47b7adce 100644 --- a/authorizer/src/asapo_authorizer/server/authorize.go +++ b/authorizer/src/asapo_authorizer/server/authorize.go @@ -111,13 +111,21 @@ func findBeamtimeMetaFromBeamline(beamline string) (beamtimeMeta, error) { online_path := settings.CurrentBeamlinesFolder + sep + beamline + sep + "current" matches, err := filepath.Glob(online_path + sep + pattern) - if err != nil || len(matches) != 1 { + if err != nil { return beamtimeMeta{}, err } + if len(matches) != 1 { + return beamtimeMeta{}, errors.New("more than one beamtime-metadata file in folder") + } + meta, err := beamtimeMetaFromJson(matches[0]) if (err != nil) { return beamtimeMeta{}, err } + if meta.BeamtimeId == "" || meta.OfflinePath=="" || meta.Beamline == ""{ + return beamtimeMeta{}, errors.New("cannot set meta fields from beamtime file") + } + meta.OnlinePath = online_path return meta, nil } @@ -253,8 +261,8 @@ func authorize(request authorizationRequest, creds SourceCredentials) (beamtimeM } meta.AccessTypes = accessTypes - log.Debug("authorized beamtime " + meta.BeamtimeId + " for " + request.OriginHost + " in " + - meta.Beamline+", type "+meta.Type) + log.Debug("authorized creds bl/bt: ", creds.Beamline+"/"+creds.BeamtimeId+", beamtime " + meta.BeamtimeId + " for " + request.OriginHost + " in " + + meta.Beamline+", type "+meta.Type, "online path "+meta.OnlinePath + ", offline path "+meta.OfflinePath) return meta, nil } diff --git a/authorizer/src/asapo_authorizer/server/authorize_test.go b/authorizer/src/asapo_authorizer/server/authorize_test.go index e4448cc69..11c072156 100644 --- a/authorizer/src/asapo_authorizer/server/authorize_test.go +++ b/authorizer/src/asapo_authorizer/server/authorize_test.go @@ -126,7 +126,8 @@ func TestAuthorizeDefaultOK(t *testing.T) { var beamtime_meta_online =` { "beamline": "bl1", -"beamtimeId": "test_online" +"beamtimeId": "test_online", +"corePath": "asap3/petra3/gpfs/p07/2020/data/11111111" } ` @@ -143,7 +144,7 @@ var beamtime_meta =` "beamline_alias": "P07", "beamtimeId": "11111111", "contact": "None", -"core-path": "asap3/petra3/gpfs/p07/2020/data/11111111", +"corePath": "asap3/petra3/gpfs/p07/2020/data/11111111", "event-end": "2020-03-03 09:00:00", "event-start": "2020-03-02 09:00:00", "facility": "PETRA III", @@ -185,29 +186,29 @@ var authTests = [] struct { {"processed","test","auto","dataSource", prepareUserToken("bt_test",[]string{}),"127.0.0.2",http.StatusUnauthorized,"empty access types", ""}, {"processed","test","auto","dataSource", prepareUserToken("bt_test",[]string{"write"}),"127.0.0.2",http.StatusOK,"user source with correct token", - `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["write"]}`}, + `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["write"]}`}, {"processed","test_online","auto","dataSource", prepareUserToken("bt_test_online",[]string{"read"}),"127.0.0.1",http.StatusOK,"with online path, processed type", - `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"","source-type":"processed","access-types":["read"]}`}, + `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"","source-type":"processed","access-types":["read"]}`}, {"processed","test1","auto","dataSource", prepareUserToken("bt_test1",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"correct token, beamtime not found", ""}, {"processed","test","auto","dataSource", prepareUserToken("wrong",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"user source with wrong token", ""}, {"processed","test","bl1","dataSource", prepareUserToken("bt_test",[]string{"read"}),"127.0.0.1",http.StatusOK,"correct beamline given", - `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["read"]}`}, + `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["read"]}`}, {"processed","test","bl2","dataSource", prepareUserToken("bt_test",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"incorrect beamline given", ""}, {"processed","auto","p07", "dataSource", prepareUserToken("bl_p07",[]string{"read"}),"127.0.0.1",http.StatusOK,"beamtime found", - `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"","source-type":"processed","access-types":["read"]}`}, + `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","corePath":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"","source-type":"processed","access-types":["read"]}`}, {"processed","auto","p07", "dataSource", prepareUserToken("bl_p06",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"wrong token", ""}, {"processed","auto","p08", "dataSource", prepareUserToken("bl_p08",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"beamtime not found", ""}, {"raw","test_online","auto","dataSource", "","127.0.0.1",http.StatusOK,"raw type", - `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-types":["read","write"]}`}, + `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-types":["read","write"]}`}, {"raw","test_online","auto","dataSource", "","127.0.0.1",http.StatusOK,"raw type", - `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-types":["read","write"]}`}, + `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-types":["read","write"]}`}, {"raw","auto","p07","dataSource", "","127.0.0.1",http.StatusOK,"raw type, auto beamtime", - `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"./p07/current","source-type":"raw","access-types":["read","write"]}`}, + `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","corePath":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"./p07/current","source-type":"raw","access-types":["read","write"]}`}, {"raw","auto","p07","noldap", "","127.0.0.1",http.StatusNotFound,"no conection to ldap", ""}, {"raw","test_online","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"raw type, wrong origin host", @@ -215,7 +216,7 @@ var authTests = [] struct { {"raw","test","auto","dataSource", prepareUserToken("bt_test",[]string{"read"}),"127.0.0.1",http.StatusUnauthorized,"raw when not online", ""}, {"processed","test","auto","dataSource", "","127.0.0.1:1001",http.StatusOK,"processed without token", - `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["read","write"]}`}, + `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","corePath":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-types":["read","write"]}`}, {"processed","test","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"processed without token, wrong host", ""}, } diff --git a/authorizer/src/asapo_authorizer/server/server.go b/authorizer/src/asapo_authorizer/server/server.go index 8e26efcf4..f55f72f2a 100644 --- a/authorizer/src/asapo_authorizer/server/server.go +++ b/authorizer/src/asapo_authorizer/server/server.go @@ -9,7 +9,7 @@ type beamtimeMeta struct { BeamtimeId string `json:"beamtimeId"` Beamline string `json:"beamline"` DataSource string `json:"dataSource"` - OfflinePath string `json:"core-path"` + OfflinePath string `json:"corePath"` OnlinePath string `json:"beamline-path"` Type string `json:"source-type"` AccessTypes []string `json:"access-types"` diff --git a/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json b/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json index 5225327c4..b6c3d5534 100644 --- a/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json +++ b/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json @@ -1,9 +1,9 @@ { "Port": {{ .Values.ownServices.authorizer.port }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test/2019/data/asapo_test"}, - {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test1/2019/data/asapo_test1"}, - {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test2/2019/data/asapo_test2"}], + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test/2019/data/asapo_test"}, + {"beamtimeId":"asapo_test1","beamline":"test1","corePath":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test1/2019/data/asapo_test1"}, + {"beamtimeId":"asapo_test2","beamline":"test2","corePath":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test2/2019/data/asapo_test2"}], "RootBeamtimesFolder":"{{ .Values.common.offlineDir }}", "CurrentBeamlinesFolder":"{{ .Values.common.onlineDir }}", "UserSecretFile":"/etc/authorizer/auth_secret.key", diff --git a/deploy/asapo_services/scripts/authorizer.json.tpl b/deploy/asapo_services/scripts/authorizer.json.tpl index 6e6392920..f3a66ed5a 100644 --- a/deploy/asapo_services/scripts/authorizer.json.tpl +++ b/deploy/asapo_services/scripts/authorizer.json.tpl @@ -1,9 +1,9 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test/2019/data/asapo_test", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test/current"}, - {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test1/2019/data/asapo_test1", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test1/current"}, - {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test2/2019/data/asapo_test2", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test2/current"}], + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test/2019/data/asapo_test", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test/current"}, + {"beamtimeId":"asapo_test1","beamline":"test1","corePath":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test1/2019/data/asapo_test1", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test1/current"}, + {"beamtimeId":"asapo_test2","beamline":"test2","corePath":"{{ env "NOMAD_META_offline_dir" }}/test_facility/gpfs/test2/2019/data/asapo_test2", "beamline-path":"{{ env "NOMAD_META_online_dir" }}/test2/current"}], "RootBeamtimesFolder":"{{ env "NOMAD_META_offline_dir" }}", "CurrentBeamlinesFolder":"{{ env "NOMAD_META_online_dir" }}", "UserSecretFile":"/local/secret.key", diff --git a/receiver/src/request_handler/request_handler_authorize.cpp b/receiver/src/request_handler/request_handler_authorize.cpp index 314b351a4..e7e433d59 100644 --- a/receiver/src/request_handler/request_handler_authorize.cpp +++ b/receiver/src/request_handler/request_handler_authorize.cpp @@ -16,14 +16,14 @@ std::string RequestHandlerAuthorize::GetRequestString(const Request* request, co return request_string; } -Error RequestHandlerAuthorize::ErrorFromAuthorizationServerResponse(const Error& err, HttpCode code) const { +Error RequestHandlerAuthorize::ErrorFromAuthorizationServerResponse(const Error& err, const std::string response,HttpCode code) const { if (err) { return asapo::ReceiverErrorTemplates::kInternalServerError.Generate("cannot authorize request: " + err->Explain()); } else { if (code != HttpCode::Unauthorized) { - return asapo::ReceiverErrorTemplates::kInternalServerError.Generate("return code " + std::to_string(int(code))); + return asapo::ReceiverErrorTemplates::kInternalServerError.Generate(response+" return code " + std::to_string(int(code))); } - return asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate("return code " + std::to_string(int(code))); + return asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate(response); } } @@ -44,7 +44,7 @@ Error RequestHandlerAuthorize::Authorize(Request* request, const char* source_cr auto response = http_client__->Post(GetReceiverConfig()->authorization_server + "/authorize", "", request_string, &code, &err); if (err || code != HttpCode::OK) { - auto auth_error = ErrorFromAuthorizationServerResponse(err, code); + auto auth_error = ErrorFromAuthorizationServerResponse(err,response, code); log__->Error("failure authorizing at " + GetReceiverConfig()->authorization_server + " request: " + request_string + " - " + auth_error->Explain()); @@ -57,14 +57,14 @@ Error RequestHandlerAuthorize::Authorize(Request* request, const char* source_cr JsonStringParser parser{response}; (err = parser.GetString("beamtimeId", &beamtime_id_)) || (err = parser.GetString("dataSource", &data_source_)) || - (err = parser.GetString("core-path", &offline_path_)) || + (err = parser.GetString("corePath", &offline_path_)) || (err = parser.GetString("beamline-path", &online_path_)) || (err = parser.GetString("source-type", &stype)) || (err = parser.GetArrayString("access-types", &access_types)) || (err = GetSourceTypeFromString(stype, &source_type_)) || (err = parser.GetString("beamline", &beamline_)); if (err) { - return ErrorFromAuthorizationServerResponse(err, code); + return ErrorFromAuthorizationServerResponse(err,"", code); } err = CheckAccessType(access_types); diff --git a/receiver/src/request_handler/request_handler_authorize.h b/receiver/src/request_handler/request_handler_authorize.h index 3e5e44c31..adbb7b5af 100644 --- a/receiver/src/request_handler/request_handler_authorize.h +++ b/receiver/src/request_handler/request_handler_authorize.h @@ -31,7 +31,7 @@ class RequestHandlerAuthorize final: public ReceiverRequestHandler { Error ProcessAuthorizationRequest(Request* request) const; Error ProcessOtherRequest(Request* request) const; Error Authorize(Request* request, const char* source_credentials) const; - Error ErrorFromAuthorizationServerResponse(const Error& err, HttpCode code) const; + Error ErrorFromAuthorizationServerResponse(const Error& err, const std::string response, HttpCode code) const; Error ProcessReAuthorization(Request* request) const; bool NeedReauthorize() const; std::string GetRequestString(const Request* request, const char* source_credentials) const; diff --git a/receiver/unittests/request_handler/test_request_handler_authorizer.cpp b/receiver/unittests/request_handler/test_request_handler_authorizer.cpp index e34fa8423..d6309ad3b 100644 --- a/receiver/unittests/request_handler/test_request_handler_authorizer.cpp +++ b/receiver/unittests/request_handler/test_request_handler_authorizer.cpp @@ -116,15 +116,13 @@ class AuthorizerHandlerTests : public Test { Return("{\"beamtimeId\":\"" + expected_beamtime_id + "\",\"dataSource\":" + "\"" + expected_data_source + "\",\"beamline-path\":" + "\"" + expected_beamline_path + - "\",\"core-path\":" + "\"" + expected_core_path + + "\",\"corePath\":" + "\"" + expected_core_path + "\",\"source-type\":" + "\"" + expected_source_type_str + "\",\"beamline\":" + "\"" + expected_beamline + "\",\"access-types\":" + expected_access_type_str + "}") )); if (code != HttpCode::OK) { EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("failure authorizing"), - HasSubstr("return code"), - HasSubstr(std::to_string(int(code))), HasSubstr(expected_source_type_str), HasSubstr(expected_beamtime_id), HasSubstr(expected_data_source), diff --git a/tests/automatic/authorizer/check_authorize/CMakeLists.txt b/tests/automatic/authorizer/check_authorize/CMakeLists.txt index 9847c8707..d0f3cdacc 100644 --- a/tests/automatic/authorizer/check_authorize/CMakeLists.txt +++ b/tests/automatic/authorizer/check_authorize/CMakeLists.txt @@ -18,6 +18,7 @@ configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/auth_secret.key auth configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/auth_secret_admin.key auth_secret_admin.key COPYONLY) configure_file(beamtime-metadata-11111111.json beamtime-metadata-11111111.json COPYONLY) +configure_file(beamtime-metadata-11111112.json beamtime-metadata-11111112.json COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/settings.json.in settings.json @ONLY) add_script_test("${TARGET_NAME}-authorize" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME>" nomem diff --git a/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111111.json b/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111111.json index 9270dbbef..baac73e90 100644 --- a/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111111.json +++ b/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111111.json @@ -10,7 +10,7 @@ "beamline_alias": "P07", "beamtimeId": "11111111", "contact": "None", - "core-path": "/asap3/petra3/gpfs/p07/2020/data/11111111", + "corePath": "/asap3/petra3/gpfs/p07/2020/data/11111111", "event-end": "2020-03-03 09:00:00", "event-start": "2020-03-02 09:00:00", "facility": "PETRA III", diff --git a/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111112.json b/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111112.json new file mode 100644 index 000000000..1370eb6b0 --- /dev/null +++ b/tests/automatic/authorizer/check_authorize/beamtime-metadata-11111112.json @@ -0,0 +1,36 @@ +{ + "applicant": { + "email": "test", + "institute": "test", + "lastname": "test", + "userId": "1234", + "username": "test" + }, + "beamline": "p08", + "beamline_alias": "P08", + "beamtimeId": "11111112", + "contact": "None", + "core-path": "/asap3/petra3/gpfs/p07/2020/data/11111112", + "event-end": "2020-03-03 09:00:00", + "event-start": "2020-03-02 09:00:00", + "facility": "PETRA III", + "generated": "2020-02-22 22:37:16", + "pi": { + "email": "test", + "institute": "test", + "lastname": "test", + "userId": "14", + "username": "test" + }, + "proposalId": "12345678", + "proposalType": "H", + "title": "In-House Research (P07)", + "unixId": "None", + "users": { + "door-db": [ + "test" + ], + "special": [], + "unknown": [] + } +} diff --git a/tests/automatic/authorizer/check_authorize/check_linux.sh b/tests/automatic/authorizer/check_authorize/check_linux.sh index 5eb25bcc3..26864b195 100644 --- a/tests/automatic/authorizer/check_authorize/check_linux.sh +++ b/tests/automatic/authorizer/check_authorize/check_linux.sh @@ -17,7 +17,9 @@ authorizeid=`echo $!` mkdir -p asap3/petra3/gpfs/p00/2019/comissioning/c20180508-000-COM20181 mkdir -p asap3/petra3/gpfs/p00/2019/data/11000015 mkdir -p beamline/p07/current -cp beamtime-metadata* beamline/p07/current/ +mkdir -p beamline/p08/current +cp beamtime-metadata-11111111.json beamline/p07/current/ +cp beamtime-metadata-11111112.json beamline/p08/current/ #tokens @@ -52,6 +54,9 @@ curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\" curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p07 curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep /asap3/petra3/gpfs/p07/2020/data/11111111 +#wrong data in metafile +curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p08%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep "cannot set meta fields" + #read access curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep read diff --git a/tests/automatic/authorizer/check_authorize/check_windows.bat b/tests/automatic/authorizer/check_authorize/check_windows.bat index 866756d98..9de776714 100644 --- a/tests/automatic/authorizer/check_authorize/check_windows.bat +++ b/tests/automatic/authorizer/check_authorize/check_windows.bat @@ -7,7 +7,7 @@ ping 192.0.2.1 -n 1 -w 1000 > nul mkdir asap3\petra3\gpfs\p00\2019\comissioning\c20180508-000-COM20181 mkdir beamline\p07\current -copy beamtime-metadata* beamline\p07\current\ /y +copy beamtime-metadata-11111111.json beamline\p07\current\ /y C:\Curl\curl.exe -v --silent --data "{\"SourceCredentials\":\"processed%%c20180508-000-COM20181%%%%detector%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr c20180508-000-COM20181 || goto :error C:\Curl\curl.exe -v --silent --data "{\"SourceCredentials\":\"processed%%c20180508-000-COM20181%%auto%%detector%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr p00 || goto :error diff --git a/tests/automatic/full_chain/simple_chain_raw/beamtime-metadata-11111111.json b/tests/automatic/full_chain/simple_chain_raw/beamtime-metadata-11111111.json index 9270dbbef..baac73e90 100644 --- a/tests/automatic/full_chain/simple_chain_raw/beamtime-metadata-11111111.json +++ b/tests/automatic/full_chain/simple_chain_raw/beamtime-metadata-11111111.json @@ -10,7 +10,7 @@ "beamline_alias": "P07", "beamtimeId": "11111111", "contact": "None", - "core-path": "/asap3/petra3/gpfs/p07/2020/data/11111111", + "corePath": "/asap3/petra3/gpfs/p07/2020/data/11111111", "event-end": "2020-03-03 09:00:00", "event-start": "2020-03-02 09:00:00", "facility": "PETRA III", diff --git a/tests/automatic/producer/aai/beamtime-metadata-11111111.json b/tests/automatic/producer/aai/beamtime-metadata-11111111.json index 65820fcb0..a26e5bcb0 100644 --- a/tests/automatic/producer/aai/beamtime-metadata-11111111.json +++ b/tests/automatic/producer/aai/beamtime-metadata-11111111.json @@ -10,7 +10,7 @@ "beamline_alias": "P07", "beamtimeId": "11111111", "contact": "None", - "core-path": "/tmp/asapo/receiver/files/test_facility/gpfs/p07/2019/data/11111111", + "corePath": "/tmp/asapo/receiver/files/test_facility/gpfs/p07/2019/data/11111111", "event-end": "2020-03-03 09:00:00", "event-start": "2020-03-02 09:00:00", "facility": "PETRA III", diff --git a/tests/automatic/producer/aai/producer_aai.py b/tests/automatic/producer/aai/producer_aai.py index 4c4cdf41f..8828b87ab 100644 --- a/tests/automatic/producer/aai/producer_aai.py +++ b/tests/automatic/producer/aai/producer_aai.py @@ -46,7 +46,7 @@ fname = 'beamline/p07/current/beamtime-metadata-11111111.json' with open(fname) as json_file: data = json.load(json_file) data['beamtimeId']='22222222' -data['core-path']=data['core-path'].replace('11111111','22222222') +data['corePath']=data['corePath'].replace('11111111','22222222') with open(fname, 'w') as outfile: json.dump(data, outfile) @@ -59,7 +59,7 @@ producer.send_file(1, local_path = "./file1", exposed_path = "processed/"+data_s producer.wait_requests_finished(10000) data['beamtimeId']='11111111' -data['core-path']=data['core-path'].replace('22222222','11111111') +data['corePath']=data['corePath'].replace('22222222','11111111') with open(fname, 'w') as outfile: json.dump(data, outfile) diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.lin b/tests/automatic/settings/authorizer_settings.json.tpl.lin index e3cc0585b..62e187d4e 100644 --- a/tests/automatic/settings/authorizer_settings.json.tpl.lin +++ b/tests/automatic/settings/authorizer_settings.json.tpl.lin @@ -1,10 +1,10 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test/2019/data/asapo_test", + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"/tmp/asapo/receiver/files/test_facility/gpfs/test/2019/data/asapo_test", "beamline-path":"/tmp/asapo/receiver/files/beamline/test/current"}, - {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test1/2019/data/asapo_test1"}, - {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test2/2019/data/asapo_test2"}], + {"beamtimeId":"asapo_test1","beamline":"test1","corePath":"/tmp/asapo/receiver/files/test_facility/gpfs/test1/2019/data/asapo_test1"}, + {"beamtimeId":"asapo_test2","beamline":"test2","corePath":"/tmp/asapo/receiver/files/test_facility/gpfs/test2/2019/data/asapo_test2"}], "UserSecretFile":"auth_secret.key", "AdminSecretFile":"auth_secret_admin.key", "TokenDurationMin":600, diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.win b/tests/automatic/settings/authorizer_settings.json.tpl.win index 31ea1eb10..810ad2e5a 100644 --- a/tests/automatic/settings/authorizer_settings.json.tpl.win +++ b/tests/automatic/settings/authorizer_settings.json.tpl.win @@ -1,10 +1,10 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test\\2019\\data\\asapo_test", + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test\\2019\\data\\asapo_test", "beamline-path":"c:\\tmp\\asapo\\receiver\\files\\beamline\\test\\current"}, - {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test1\\2019\\data\\asapo_test1"}, - {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test2\\2019\\data\\asapo_test2"}], + {"beamtimeId":"asapo_test1","beamline":"test1","corePath":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test1\\2019\\data\\asapo_test1"}, + {"beamtimeId":"asapo_test2","beamline":"test2","corePath":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test2\\2019\\data\\asapo_test2"}], "UserSecretFile":"auth_secret.key", "AdminSecretFile":"auth_secret_admin.key", "TokenDurationMin":600, -- GitLab