Skip to content
Snippets Groups Projects
Commit 4c7ac8cf authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

authorizer tests

parent 084806a5
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,6 @@ import (
"asapo_common/utils"
"encoding/json"
"errors"
"fmt"
"net/http"
"path/filepath"
"strings"
......@@ -62,8 +61,8 @@ func getBeamlineFromIP(ip string) (string, error) {
func beamtimeInfoFromMatch(match string) (beamtimeInfo,error) {
match = strings.TrimPrefix(match, settings.RootBeamtimesFolder)
match = strings.TrimPrefix(match, "/")
vars := strings.Split(match,"/")
match = strings.TrimPrefix(match, string(filepath.Separator))
vars := strings.Split(match,string(filepath.Separator))
if len(vars)!=6 {
return beamtimeInfo{},errors.New("bad pattern")
}
......@@ -79,8 +78,9 @@ func beamtimeInfoFromMatch(match string) (beamtimeInfo,error) {
}
func findBeamtime(beamtime_id string) (beamtimeInfo,bool) {
matches, err := filepath.Glob(settings.RootBeamtimesFolder+"/*/gpfs/*/*/*/"+beamtime_id)
fmt.Println(matches)
sep := string(filepath.Separator)
pattern := sep+"*"+sep+"gpfs"+sep+"*"+sep+"*"+sep+"*"+sep
matches, err := filepath.Glob(settings.RootBeamtimesFolder+pattern+beamtime_id)
if err!=nil || len(matches)==0 {
return beamtimeInfo{},false
......
......@@ -5,6 +5,8 @@ start /B "" "%full_name%" -config settings.json
ping 1.0.0.0 -n 1 -w 100 > nul
mkdir asap3\petra3\gpfs\p01\2019\comissioning\c20180508-000-COM20181
C:\Curl\curl.exe -v --silent --data "{\"SourceCredentials\":\"c20180508-000-COM20181%%stream%%\",\"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\":\"c20180508-000-COM20181%%stream%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr p01 || goto :error
C:\Curl\curl.exe -v --silent --data "{\"SourceCredentials\":\"c20180508-000-COM20181%%stream%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr stream || goto :error
......@@ -21,3 +23,4 @@ exit /b 1
:clean
Taskkill /IM "%short_name%" /F
rmdir /S /Q asap3
......@@ -6,10 +6,13 @@ SET beamline2=test2
SET stream=detector
SET receiver_root_folder=c:\tmp\asapo\receiver\files
SET receiver_folder1="%receiver_root_folder%\%beamline1%\%beamtime_id1%"
SET receiver_folder2="%receiver_root_folder%\%beamline2%\%beamtime_id2%"
SET facility=test_facility
SET year=2019
SET receiver_folder1="%receiver_root_folder%\%facility%\gpfs\%beamline1%\%year%\data\%beamtime_id1%"
SET receiver_folder2="%receiver_root_folder%\%facility%\gpfs\%beamline2%\%year%\data\%beamtime_id2%"
"%3" token -secret auth_secret.key %beamtime_id1% > token
set /P token1=< token
"%3" token -secret auth_secret.key %beamtime_id2% > token
......
#rmdir /S /Q test
icacls test_noaccess1 /grant:r users:D
rmdir /S /Q test_noaccess1
#icacls test_noaccess1 /grant:r users:D
#rmdir /S /Q test_noaccess1
rmdir /S /Q test
icacls file_noaccess /grant:r users:D
del file_noaccess
#icacls file_noaccess /grant:r users:D
#del file_noaccess
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment