Added check_credentials()
authorDaniel Kouřil <kouril@ics.muni.cz>
Fri, 18 Feb 2011 10:27:44 +0000 (10:27 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Fri, 18 Feb 2011 10:27:44 +0000 (10:27 +0000)
org.glite.testsuites.ctb/LB/tests/lb-common.sh

index ac07138..352e274 100755 (executable)
@@ -253,3 +253,21 @@ function test_args()
         echo $@
 }
 
+function check_credentials()
+{
+       my_GRIDPROXYINFO=${GRIDPROXYINFO}
+       if [ "$1" != "" ]; then
+               my_GRIDPROXYINFO="${GRIDPROXYINFO} -f $1"
+       fi
+
+       timeleft=`${my_GRIDPROXYINFO} | ${SYS_GREP} -E "^timeleft" | ${SYS_SED} "s/timeleft\s*:\s//"`
+       if [ "$timeleft" = "" ]; then
+               print_error "No credentials"
+               return 1
+       fi
+       if [ "$timeleft" = "0:00:00" ]; then
+               print_error "Credentials expired"
+               return 1
+       fi
+       return 0
+}