From 293f08172c3c17ff495df6fb0ce4ce3098460e81 Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Fri, 17 Jan 2020 17:38:10 +0100
Subject: [PATCH] authorizer uses asap3 folder to extract beamtime info

---
 .../src/asapo_authorizer/server/authorize.go  |  51 ++++++--
 .../asapo_authorizer/server/authorize_test.go | 117 +++++++++---------
 .../src/asapo_authorizer/server/server.go     |  12 +-
 .../scripts/authorizer.json.tpl               |   6 +-
 deploy/nomad_consul_docker/jobs-stop          |   6 +-
 .../authorizer/check_authorize/CMakeLists.txt |   4 +-
 .../authorizer/check_authorize/check_linux.sh |  15 ++-
 .../check_authorize/settings.json.in          |   2 +-
 .../settings/authorizer_settings.json.tpl     |   6 +-
 .../broker_debug_local/authorizer.json.tpl    |   6 +-
 .../authorizer.json                           |   2 +-
 .../authorizer.json                           |   2 +-
 .../python_tests/producer/authorizer.json.tpl |   6 +-
 .../authorizer.json.tpl                       |   6 +-
 .../receiver_debug_local/authorizer.json.tpl  |   6 +-
 15 files changed, 148 insertions(+), 99 deletions(-)

diff --git a/authorizer/src/asapo_authorizer/server/authorize.go b/authorizer/src/asapo_authorizer/server/authorize.go
index 9b8e0d099..ff7f4bf0f 100644
--- a/authorizer/src/asapo_authorizer/server/authorize.go
+++ b/authorizer/src/asapo_authorizer/server/authorize.go
@@ -5,6 +5,7 @@ import (
 	"asapo_common/utils"
 	"encoding/json"
 	"errors"
+	"fmt"
 	"net/http"
 	"path/filepath"
 	"strings"
@@ -72,14 +73,42 @@ func checkBeamtimeExistsInStrings(beamtime_id string, lines []string) (string,bo
 	return "",false
 }
 
-func beamtimeRegistered(beamtime_id string) (string,bool) {
-	lines, err := utils.ReadStringsFromFile(settings.BeamtimeBeamlineMappingFile)
+func beamtimeInfoFromMatch(match string) (beamtimeInfo,error) {
+	match = strings.TrimPrefix(match, settings.RootBeamtimesFolder)
+	match = strings.TrimPrefix(match, "/")
+	vars := strings.Split(match,"/")
+	if len(vars)!=6 {
+		return beamtimeInfo{},errors.New("bad pattern")
+	}
+	var bt beamtimeInfo
+	ignoredFoldersAfterGpfs:=[]string{"common","BeamtimeUsers","state","support"}
+	if utils.StringInSlice(vars[2],ignoredFoldersAfterGpfs) {
+		return beamtimeInfo{},errors.New("skipped fodler")
+	}
 
-	if err != nil || len(lines) < 3 {
-		return "",false
+	bt.Facility,bt.Beamline,bt.Year,bt.BeamtimeId = vars[0],vars[2],vars[3],vars[5]
+
+	return bt,nil
+}
+
+func findBeamtime(beamtime_id string) (beamtimeInfo,bool) {
+	matches, err := filepath.Glob(settings.RootBeamtimesFolder+"/*/gpfs/*/*/*/"+beamtime_id)
+	fmt.Println(matches)
+
+	if err!=nil || len(matches)==0 {
+		return beamtimeInfo{},false
 	}
-	lines = lines[2:]
-	return checkBeamtimeExistsInStrings(beamtime_id, lines)
+
+	for _,match := range (matches) {
+		btInfo,err := beamtimeInfoFromMatch(match)
+		if err!= nil {
+			continue
+		}
+		if btInfo.BeamtimeId == beamtime_id {
+			return btInfo,true
+		}
+	}
+	return beamtimeInfo{},false
 }
 
 func alwaysAllowed(creds SourceCredentials)(beamtimeInfo,bool) {
@@ -114,7 +143,7 @@ func authorizeByToken(creds SourceCredentials) bool {
 	token_expect, _ := auth.GenerateToken(&creds.BeamtimeId)
 
 	if creds.Token != token_expect {
-		log.Error("wrong token for beamtime" + creds.BeamtimeId)
+		log.Error("wrong token for beamtime " + creds.BeamtimeId)
 		return false
 	}
 	return true
@@ -126,14 +155,14 @@ func authorize(request authorizationRequest,creds SourceCredentials) (beamtimeIn
 		return answer,ok
 	}
 
-	beamline,ok :=beamtimeRegistered(creds.BeamtimeId)
+	beamlineInfo,ok := findBeamtime(creds.BeamtimeId)
 	if (!ok) {
 		log.Error("cannot find beamline for " + creds.BeamtimeId)
 		return beamtimeInfo{},false
 	}
 
 	if needHostAuthorization(creds)  {
-		if !authorizeByHost(request.OriginHost,beamline) {
+		if !authorizeByHost(request.OriginHost,beamlineInfo.Beamline) {
 			return beamtimeInfo{}, false
 		}
 	} else {
@@ -143,7 +172,9 @@ func authorize(request authorizationRequest,creds SourceCredentials) (beamtimeIn
 	}
 
 	var answer beamtimeInfo
-	answer.Beamline = beamline
+	answer.Beamline = beamlineInfo.Beamline
+	answer.Facility = beamlineInfo.Facility
+	answer.Year = beamlineInfo.Year
 	answer.BeamtimeId = creds.BeamtimeId
 	answer.Stream = creds.Stream
 
diff --git a/authorizer/src/asapo_authorizer/server/authorize_test.go b/authorizer/src/asapo_authorizer/server/authorize_test.go
index e48706050..4d6a111f1 100644
--- a/authorizer/src/asapo_authorizer/server/authorize_test.go
+++ b/authorizer/src/asapo_authorizer/server/authorize_test.go
@@ -70,7 +70,7 @@ func TestSplitCreds(t *testing.T) {
 }
 
 func TestAuthorizeDefaultOK(t *testing.T) {
-	allowBeamlines([]beamtimeInfo{{"asapo_test","beamline",""}})
+	allowBeamlines([]beamtimeInfo{{"asapo_test","beamline","","2019","tf"}})
 	request :=  makeRequest(authorizationRequest{"asapo_test%%","host"})
 	w := doAuthorizeRequest("/authorize",request)
 
@@ -84,31 +84,34 @@ func TestAuthorizeDefaultOK(t *testing.T) {
 }
 
 var authTests = [] struct {
+	beamtime_id string
 	stream string
 	token string
 	status int
 	message string
 }{
-	{"stream", prepareToken("test"),http.StatusOK,"user stream with correct token"},
-	{"stream", prepareToken("wrong"),http.StatusUnauthorized,"user stream with wrong token"},
-	{"detector_aaa", prepareToken("test"),http.StatusUnauthorized,"detector stream with correct token and wroung source"},
+	{"test","stream", prepareToken("test"),http.StatusOK,"user stream with correct token"},
+	{"test1","stream", prepareToken("test1"),http.StatusUnauthorized,"correct token, beamtime not found"},
+	{"test","stream", prepareToken("wrong"),http.StatusUnauthorized,"user stream with wrong token"},
+	{"test","detector_aaa", prepareToken("test"),http.StatusUnauthorized,"detector stream with correct token and wroung source"},
 }
 func TestAuthorizeWithToken(t *testing.T) {
 	allowBeamlines([]beamtimeInfo{})
-	settings.BeamtimeBeamlineMappingFile="file.tmp"
-	beamtime_id:= "test"
-	lines :="line1\n line2\n flash bl1 "+ beamtime_id	+" start: 2018-04-24"
-	ioutil.WriteFile("file.tmp", []byte(lines), 0644)
-	defer 	os.Remove("file.tmp")
+	settings.RootBeamtimesFolder ="."
+	os.MkdirAll("tf/gpfs/bl1/2019/data/test", os.ModePerm)
+	defer 	os.RemoveAll("tf")
 
 	for _, test := range authTests {
-		request :=  makeRequest(authorizationRequest{beamtime_id+"%"+test.stream+"%"+test.token,"host"})
+		request :=  makeRequest(authorizationRequest{test.beamtime_id+"%"+test.stream+"%"+test.token,"host"})
 		w := doAuthorizeRequest("/authorize",request)
 
 		body, _ := ioutil.ReadAll(w.Body)
 		if test.status==http.StatusOK {
-			assert.Contains(t, string(body), beamtime_id, "")
+			assert.Contains(t, string(body), test.beamtime_id, "")
 			assert.Contains(t, string(body), "bl1", "")
+			assert.Contains(t, string(body), "stream", "")
+			assert.Contains(t, string(body), "2019", "")
+			assert.Contains(t, string(body), "tf", "")
 			assert.Contains(t, string(body), test.stream, "")
 		}
 
@@ -139,7 +142,8 @@ func TestAuthorizeWrongPath(t *testing.T) {
 }
 
 func TestDoNotAuthorizeIfNotInAllowed(t *testing.T) {
-	allowBeamlines([]beamtimeInfo{{"test","beamline",""}})
+	allowBeamlines([]beamtimeInfo{{"test","beamline","","2019","tf"}})
+
 	request :=  authorizationRequest{"asapo_test%%","host"}
 	creds,_ := getSourceCredentials(request)
 	_,ok := authorize(request,creds)
@@ -162,55 +166,14 @@ func TestGetBeamlineFromIP(t *testing.T) {
 	assert.NotNil(t,err, "")
 	assert.Empty(t,beamline, "")
 
-}
-func TestCheckBeamtimeExistsInStringsFalse(t *testing.T) {
-	beamInfo := beamtimeInfo{"123","bl",""}
-	lines:=[]string{"111","flash	pg2	11003932		beamtime	start: 2018-06-11","petra3	p01	c20180508-000-COM20181	commissioning"}
-	bl,ok := checkBeamtimeExistsInStrings(beamInfo.BeamtimeId,lines)
-	assert.False(t,ok, "")
-	assert.Equal(t,"",bl, "")
-}
-
-
-func TestCheckBeamtimeExistsInStringsOk(t *testing.T) {
-	beamInfo := beamtimeInfo{"11003932","pg2",""}
-	lines:=[]string{"111","flash	pg2	11003932		beamtime	start: 2018-06-11","petra3	p01	c20180508-000-COM20181	commissioning"}
-	bl,ok := checkBeamtimeExistsInStrings(beamInfo.BeamtimeId,lines)
-	assert.True(t,ok, "")
-	assert.Equal(t,bl,beamInfo.Beamline,"")
-
 }
 
 func TestAuthorizeWithFile(t *testing.T) {
 	settings.IpBeamlineMappingFolder="."
-	settings.BeamtimeBeamlineMappingFile="file.tmp"
-
-	lines :=`
-Open beam times as of  Thursday, 2018/06/21 11:32
-Faclty	BL	BeamTime Id		kind
-flash	bl1	11003924		beamtime	start: 2018-04-24
-flash	bl2	11003921		beamtime	start: 2018-06-08
-flash	fl24	11001734		beamtime	start: 2018-06-13
-flash	pg2	11003932		beamtime	start: 2018-06-11
-flash	thz	11005667		beamtime	start: 2018-05-24
-petra3	ext	50000181		beamtime	start: 2017-04-12
-petra3	ext	50000193		beamtime	start: 2017-10-12
-petra3	ext	50000202		beamtime	start: 2017-12-06
-petra3	ext	50000209		beamtime	start: 2018-02-19
-petra3	ext	50000211		beamtime	start: 2018-02-19
-petra3	ext	50000214		beamtime	start: 2018-04-23
-petra3	ext	50000215		beamtime	start: 2018-03-23
-petra3	ext	50000216		beamtime	start: 2018-03-23
-petra3	ext	50000217		beamtime	start: 2018-03-23
-petra3	ext	50000218		beamtime	start: 2018-03-23
-petra3	ext	50000219		beamtime	start: 2018-04-24
-petra3	ext	50000221		beamtime	start: 2018-06-14
-petra3	p01	11004172		beamtime	start: 2018-06-20
-petra3	p01	c20180508-000-COM20181	commissioning
-petra3	p02.1	11004341		beamtime	start: 2018-06-18
-`
-
-	ioutil.WriteFile("file.tmp", []byte(lines), 0644)
+	settings.RootBeamtimesFolder ="."
+	os.MkdirAll("tf/gpfs/bl1/2019/data/11003924", os.ModePerm)
+
+
 	ioutil.WriteFile("127.0.0.1", []byte("bl1"), 0644)
 
 
@@ -220,6 +183,9 @@ petra3	p02.1	11004341		beamtime	start: 2018-06-18
 	body, _ := ioutil.ReadAll(w.Body)
 	assert.Contains(t, string(body), "11003924", "")
 	assert.Contains(t, string(body), "bl1", "")
+	assert.Contains(t, string(body), "detector", "")
+	assert.Contains(t, string(body), "2019", "")
+	assert.Contains(t, string(body), "tf", "")
 	assert.Equal(t, http.StatusOK, w.Code, "")
 
 	request = authorizationRequest{"wrong%%","127.0.0.1"}
@@ -227,8 +193,43 @@ petra3	p02.1	11004341		beamtime	start: 2018-06-18
 	assert.Equal(t, http.StatusUnauthorized, w.Code, "")
 
 	os.Remove("127.0.0.1")
-	os.Remove("file.tmp")
+	os.RemoveAll("tf")
 
 }
 
 
+var extractBtinfoTests = [] struct {
+	root string
+	fname string
+	facility string
+	beamline string
+	year string
+	id string
+	ok bool
+}{
+	{".","tf/gpfs/bl1.01/2019/data/123","tf", "bl1.01","2019","123",true},
+	{"/blabla/tratartra","tf/gpfs/bl1.01/2019/data/123","tf", "bl1.01","2019","123",true},
+	{".","tf/gpfs/common/2019/data/123","tf", "bl1.01","2019","123",false},
+	{".","tf/gpfs/BeamtimeUsers/2019/data/123","tf", "bl1.01","2019","123",false},
+	{".","tf/gpfs/state/2019/data/123","tf", "bl1.01","2019","123",false},
+	{".","tf/gpfs/support/2019/data/123","tf", "bl1.01","2019","123",false},
+	{".","petra3/gpfs/p01/2019/comissioning/c20180508-000-COM20181","petra3", "p01","2019","c20180508-000-COM20181",true},
+
+}
+func TestGetBeamtimeInfo(t *testing.T) {
+	for _, test := range extractBtinfoTests {
+		settings.RootBeamtimesFolder=test.root
+		bt,err:=beamtimeInfoFromMatch(test.root+"/"+test.fname)
+		if test.ok {
+			assert.Equal(t,bt.Facility,test.facility)
+			assert.Equal(t,bt.Beamline,test.beamline)
+			assert.Equal(t,bt.Year,test.year)
+			assert.Equal(t,bt.BeamtimeId,test.id)
+			assert.Equal(t,bt.Facility,test.facility)
+			assert.Nil(t,err,"should not be error")
+		} else {
+			assert.NotNil(t,err,"should be error")
+		}
+	}
+
+}
diff --git a/authorizer/src/asapo_authorizer/server/server.go b/authorizer/src/asapo_authorizer/server/server.go
index e12d0d973..e0785c8f3 100644
--- a/authorizer/src/asapo_authorizer/server/server.go
+++ b/authorizer/src/asapo_authorizer/server/server.go
@@ -6,15 +6,17 @@ type  beamtimeInfo struct {
 	BeamtimeId string
 	Beamline string
 	Stream string
+	Year string
+	Facility string
 }
 
 type serverSettings struct {
-	Port             int
-	LogLevel         string
+	Port                    int
+	LogLevel                string
 	IpBeamlineMappingFolder string
-	BeamtimeBeamlineMappingFile string
-	AlwaysAllowedBeamtimes []beamtimeInfo
-	SecretFile       string
+	RootBeamtimesFolder     string
+	AlwaysAllowedBeamtimes  []beamtimeInfo
+	SecretFile              string
 }
 
 var settings serverSettings
diff --git a/deploy/asapo_services/scripts/authorizer.json.tpl b/deploy/asapo_services/scripts/authorizer.json.tpl
index 69628bf81..91fd43b3d 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"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"/local/secret.key"
 }
 
diff --git a/deploy/nomad_consul_docker/jobs-stop b/deploy/nomad_consul_docker/jobs-stop
index c4401c97c..4a2b10319 100755
--- a/deploy/nomad_consul_docker/jobs-stop
+++ b/deploy/nomad_consul_docker/jobs-stop
@@ -2,4 +2,8 @@
 
 #export NOMAD_TOKEN=`cat /var/nomad/token `
 
-cd /var/run/asapo && terraform destroy -auto-approve "$@"
+if [ -f /var/run/asapo/user_vars.tfvars ]; then
+  USER_VAR_FILE="-var-file=/var/run/asapo/user_vars.tfvars"
+fi
+
+cd /var/run/asapo && terraform destroy -auto-approve $USER_VAR_FILE "$@"
diff --git a/tests/automatic/authorizer/check_authorize/CMakeLists.txt b/tests/automatic/authorizer/check_authorize/CMakeLists.txt
index b80aa88df..5888d99f9 100644
--- a/tests/automatic/authorizer/check_authorize/CMakeLists.txt
+++ b/tests/automatic/authorizer/check_authorize/CMakeLists.txt
@@ -3,10 +3,10 @@ set(TARGET_NAME asapo-authorizer)
 ################################
 # Testing
 ################################
-file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/OpenBeamTimes.txt BEAMTIMES_FILE )
+file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/asap3 ASAP3_FOLDER )
 file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ip_bl_mapping BEAMLINES_FOLDER )
 if (WIN32)
-    string(REPLACE "\\" "\\\\" BEAMTIMES_FILE "${BEAMTIMES_FILE}")
+    string(REPLACE "\\" "\\\\" ASAP3_FOLDER "${ASAP3_FOLDER}")
     string(REPLACE "\\" "\\\\" BEAMLINES_FOLDER "${BEAMLINES_FOLDER}")
 endif()
 
diff --git a/tests/automatic/authorizer/check_authorize/check_linux.sh b/tests/automatic/authorizer/check_authorize/check_linux.sh
index 4ff8c44ce..ef9a2ed34 100644
--- a/tests/automatic/authorizer/check_authorize/check_linux.sh
+++ b/tests/automatic/authorizer/check_authorize/check_linux.sh
@@ -10,10 +10,12 @@ Cleanup() {
 	sleep 1
 }
 
-$@ -config settings.json  &
+$@ -config settings.json &
 sleep 1
 authorizeid=`echo $!`
 
+mkdir -p asap3/petra3/gpfs/p01/2019/comissioning/c20180508-000-COM20181
+mkdir -p asap3/petra3/gpfs/p01/2019/data/11000015
 curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep c20180508-000-COM20181
 curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p01
 curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep stream
@@ -21,4 +23,13 @@ curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%","
 token=onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90= #token for c20180508-000-COM20181
 
 curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep stream
-curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%bla","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
\ No newline at end of file
+curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p01
+curl -v --silent --data '{"SourceCredentials":"c20180508-000-COM20181%stream%bla","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
+
+token=dccMd3NT89i32Whz7yD4VQhmEJy6Kxc35wsBbWJLXp0= #token for 11000015
+curl -v --silent --data '{"SourceCredentials":"11000015%stream%dccMd3NT89i32Whz7yD4VQhmEJy6Kxc35wsBbWJLXp0=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p01
+
+token=Jaas_xTpkB0Zy5dFwjs4kCrY7yXMfbnW8Ca1aYhyKBs= #token for 11000016
+curl -v --silent --data '{"SourceCredentials":"11000016%stream%Jaas_xTpkB0Zy5dFwjs4kCrY7yXMfbnW8Ca1aYhyKBs=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
+
+rm -rf asap3
\ No newline at end of file
diff --git a/tests/automatic/authorizer/check_authorize/settings.json.in b/tests/automatic/authorizer/check_authorize/settings.json.in
index 22f25fcdc..57c915d54 100644
--- a/tests/automatic/authorizer/check_authorize/settings.json.in
+++ b/tests/automatic/authorizer/check_authorize/settings.json.in
@@ -1,7 +1,7 @@
 {
   "Port": 5007,
   "LogLevel":"debug",
-  "BeamtimeBeamlineMappingFile":"@BEAMTIMES_FILE@",
+  "RootBeamtimesFolder":"@ASAP3_FOLDER@",
   "IpBeamlineMappingFolder":"@BEAMLINES_FOLDER@",
   "SecretFile":"auth_secret.key"
 }
diff --git a/tests/automatic/settings/authorizer_settings.json.tpl b/tests/automatic/settings/authorizer_settings.json.tpl
index 7c3a796d2..f6d57da90 100644
--- a/tests/automatic/settings/authorizer_settings.json.tpl
+++ b/tests/automatic/settings/authorizer_settings.json.tpl
@@ -1,9 +1,9 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/broker_debug_local/authorizer.json.tpl b/tests/manual/broker_debug_local/authorizer.json.tpl
index 7c3a796d2..f6d57da90 100644
--- a/tests/manual/broker_debug_local/authorizer.json.tpl
+++ b/tests/manual/broker_debug_local/authorizer.json.tpl
@@ -1,9 +1,9 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/performance_full_chain_simple/authorizer.json b/tests/manual/performance_full_chain_simple/authorizer.json
index 0fe9f9f68..30e5ca3ba 100644
--- a/tests/manual/performance_full_chain_simple/authorizer.json
+++ b/tests/manual/performance_full_chain_simple/authorizer.json
@@ -1,7 +1,7 @@
 {
   "Port": 5007,
   "LogLevel":"info",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/performance_producer_receiver/authorizer.json b/tests/manual/performance_producer_receiver/authorizer.json
index 0fe9f9f68..30e5ca3ba 100644
--- a/tests/manual/performance_producer_receiver/authorizer.json
+++ b/tests/manual/performance_producer_receiver/authorizer.json
@@ -1,7 +1,7 @@
 {
   "Port": 5007,
   "LogLevel":"info",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/python_tests/producer/authorizer.json.tpl b/tests/manual/python_tests/producer/authorizer.json.tpl
index 7c3a796d2..f6d57da90 100644
--- a/tests/manual/python_tests/producer/authorizer.json.tpl
+++ b/tests/manual/python_tests/producer/authorizer.json.tpl
@@ -1,9 +1,9 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl b/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl
index 7c3a796d2..f6d57da90 100644
--- a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl
+++ b/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl
@@ -1,9 +1,9 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
diff --git a/tests/manual/receiver_debug_local/authorizer.json.tpl b/tests/manual/receiver_debug_local/authorizer.json.tpl
index 7c3a796d2..f6d57da90 100644
--- a/tests/manual/receiver_debug_local/authorizer.json.tpl
+++ b/tests/manual/receiver_debug_local/authorizer.json.tpl
@@ -1,9 +1,9 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
-  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"},
-  {"BeamtimeId":"asapo_test1","Beamline":"test1"},
-  {"BeamtimeId":"asapo_test2","Beamline":"test2"}],
+  "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test1","Beamline":"test1","Year":"2019","Facility":"test_facility"},
+  {"BeamtimeId":"asapo_test2","Beamline":"test2","Year":"2019","Facility":"test_facility"}],
   "SecretFile":"auth_secret.key"
 }
 
-- 
GitLab