From 074fdea977139ae67d1e9fac594b4141fac6e8f8 Mon Sep 17 00:00:00 2001
From: Julien Leduc <julien.leduc@cern.ch>
Date: Tue, 14 Jan 2020 15:55:20 +0100
Subject: [PATCH] Adding eosadmin_eos command in  to run command as an eos
 admin on ctaeos

---
 .../ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh  |  6 +++++-
 .../orchestration/tests/client_helper.sh       | 18 ++++++++++++++++++
 .../orchestration/tests/prepare_tests.sh       |  1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
index e192f2c195..0ecbf26ea4 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
@@ -220,7 +220,11 @@ fi
 
   # Add user daemon to sudoers this is to allow recalls for the moment using this command
   #  XrdSecPROTOCOL=sss xrdfs ctaeos prepare -s "/eos/ctaeos/cta/${TEST_FILE_NAME}?eos.ruid=12001&eos.rgid=1200"
-  eos vid set membership 2 +sudo
+  eos vid set membership $(id -u daemon) +sudo
+
+  # Add eosadmin1 and eosadmin2 users are sudoers
+  eos vid set membership $(id -u eosadmin1) +sudo
+  eos vid set membership $(id -u eosadmin2) +sudo
 
   eos node set ${eoshost} on
   eos space set default on
diff --git a/continuousintegration/orchestration/tests/client_helper.sh b/continuousintegration/orchestration/tests/client_helper.sh
index a2bdfcaf82..d2ad1d08ea 100644
--- a/continuousintegration/orchestration/tests/client_helper.sh
+++ b/continuousintegration/orchestration/tests/client_helper.sh
@@ -12,6 +12,7 @@
 
 EOSPOWER_USER="poweruser1"
 CTAADMIN_USER="ctaadmin2"
+EOSADMIN_USER="eosadmin1"
 USER="user1"
 
 die() {
@@ -60,3 +61,20 @@ eospower_kdestroy() {
   eospower_klist
 }
 
+eosadmin_eos() {
+  XrdSecPROTOCOL=krb5 KRB5CCNAME=/tmp/${EOSADMIN_USER}/krb5cc_0 eos -r 0 0 $@
+}
+
+eosadmin_klist() {
+  KRB5CCNAME=/tmp/${EOSADMIN_USER}/krb5cc_0 klist
+}
+
+eosadmin_kinit() {
+  KRB5CCNAME=/tmp/${EOSADMIN_USER}/krb5cc_0 kinit -kt /root/${EOSADMIN_USER}.keytab ${EOSADMIN_USER}@TEST.CTA
+  eosadmin_klist
+}
+
+eosadmin_kdestroy() {
+  KRB5CCNAME=/tmp/${EOSADMIN_USER}/krb5cc_0 kdestroy
+  eosadmin_klist
+}
diff --git a/continuousintegration/orchestration/tests/prepare_tests.sh b/continuousintegration/orchestration/tests/prepare_tests.sh
index 38be1e8884..f7cc72ad1b 100755
--- a/continuousintegration/orchestration/tests/prepare_tests.sh
+++ b/continuousintegration/orchestration/tests/prepare_tests.sh
@@ -189,6 +189,7 @@ kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin admin add --username c
 
 kubectl --namespace=${NAMESPACE} exec kdc cat /root/ctaadmin2.keytab | kubectl --namespace=${NAMESPACE} exec -i client --  bash -c "cat > /root/ctaadmin2.keytab; mkdir -p /tmp/ctaadmin2"
 kubectl --namespace=${NAMESPACE} exec kdc cat /root/poweruser1.keytab | kubectl --namespace=${NAMESPACE} exec -i client --  bash -c "cat > /root/poweruser1.keytab; mkdir -p /tmp/poweruser1"
+kubectl --namespace=${NAMESPACE} exec kdc cat /root/eosadmin1.keytab | kubectl --namespace=${NAMESPACE} exec -i client --  bash -c "cat > /root/eosadmin1.keytab; mkdir -p /tmp/eosadmin1"
 
 ###
 # Filling services in DNS on all pods
-- 
GitLab