test_abd_bi_bw_link.sh 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/env bash
  2. trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
  3. LOCATION=$(which gnunet-config)
  4. if [ -z $LOCATION ]
  5. then
  6. LOCATION="gnunet-config"
  7. fi
  8. $LOCATION --version 1> /dev/null
  9. if test $? != 0
  10. then
  11. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  12. exit 77
  13. fi
  14. rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
  15. which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
  16. gnunet-arm -s -c test_abd_lookup.conf
  17. gnunet-identity -C a -c test_abd_lookup.conf
  18. gnunet-identity -C b -c test_abd_lookup.conf
  19. gnunet-identity -C c -c test_abd_lookup.conf
  20. gnunet-identity -C d -c test_abd_lookup.conf
  21. gnunet-identity -C e -c test_abd_lookup.conf
  22. gnunet-identity -C f -c test_abd_lookup.conf
  23. gnunet-identity -C g -c test_abd_lookup.conf
  24. AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
  25. BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
  26. CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
  27. DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
  28. EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
  29. FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
  30. GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
  31. gnunet-identity -d
  32. # (1) (A.a) <- B.b
  33. # (2) (B.b) <- G.g.c
  34. # (3) (G.g) <- C
  35. # (3) C.c <- (D.D)
  36. # (4) D.d <- (E.e)
  37. # (5) E.e <- (F)
  38. # BIDIRECTIONAL
  39. gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
  40. gnunet-namestore -D -z a
  41. gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$GKEY g.c" --ttl=5m -c test_abd_lookup.conf
  42. gnunet-namestore -D -z b
  43. gnunet-abd --createIssuerSide --ego=g --attribute="g" --subject="$CKEY" --ttl=5m -c test_abd_lookup.conf
  44. gnunet-namestore -D -z b
  45. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
  46. gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
  47. gnunet-namestore -D -z d
  48. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
  49. gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
  50. gnunet-namestore -D -z e
  51. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
  52. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
  53. gnunet-namestore -D -z f
  54. # Starting to resolve
  55. echo "+++ Starting to Resolve +++"
  56. DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
  57. echo $DELS
  58. echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
  59. gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
  60. RES=$?
  61. # Cleanup properly
  62. gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
  63. gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
  64. gnunet-namestore -z g -d -n "g" -t ATTR -c test_abd_lookup.conf
  65. gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
  66. gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
  67. gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
  68. gnunet-arm -e -c test_abd_lookup.conf
  69. if [ "$RES" == 0 ]
  70. then
  71. exit 0
  72. else
  73. echo "FAIL: Failed to verify credential."
  74. exit 1
  75. fi