auto_prefix_propagate: "cannot read certificate" bugfix

Change-Id: I87d5de0a27036e9ef880132cc47e77e45478f665
refs: #3825
diff --git a/test_auto_prefix_propagate/A.sh b/test_auto_prefix_propagate/A.sh
index ab82d7f..a1dffb1 100755
--- a/test_auto_prefix_propagate/A.sh
+++ b/test_auto_prefix_propagate/A.sh
@@ -6,7 +6,7 @@
 repoHost='localhost'
 repoPort='9527'
 nfdConf='host.nfd.conf'
-systemNfdConf='/usr/local/etc/ndn/nfd.conf'
+systemNfdConf='/usr/local/etc/ndn/nfd.conf.sample'
 testLog='host.test.log'
 nfdLog='host.nfd.log'
 
@@ -165,10 +165,9 @@
 }
 
 generate_anchor() {
-    certFile='auto-propagate.anchor.cert'
+    certFile='anchor.cert'
     ndnsec-export -o $certFile $1 >>$testLog 2>&1
-    cert=$(cat $certFile) && rm $certFile
-    echo $cert
+    echo $certFile
 }
 
 while getopts "a:cp" arg
diff --git a/test_auto_prefix_propagate/B.sh b/test_auto_prefix_propagate/B.sh
index 4784a31..4bc5f0c 100755
--- a/test_auto_prefix_propagate/B.sh
+++ b/test_auto_prefix_propagate/B.sh
@@ -1,9 +1,7 @@
 #!/usr/bin/env bash
 
-defaultIdentity=
-hubIdentity='/auto-prefix-propagate/hub'
 nfdConf='hub.nfd.conf'
-systemNfdConf='/usr/local/etc/ndn/nfd.conf'
+systemNfdConf='/usr/local/etc/ndn/nfd.conf.sample'
 testLog='hub.test.log'
 nfdLog='hub.nfd.log'
 
@@ -38,33 +36,12 @@
     LOG "Killing NFD process!"
     kill_process nfd
     kill_process ndn-autoconfig-server
-
-    LOG "Deleting the hub identity"
-    delete_identity "$hubIdentity"
-
-    LOG "Reset the default identity"
-    if [[ -n "$defaultIdentity" ]]; then
-        if [[ $(ndnsec-list | grep -c "$defaultIdentity$") -gt 0 ]]; then
-            ndnsec-set-default $defaultIdentity
-        fi
-    else
-        r=$(ndnsec-list)
-        if [[ -n "$r" ]]; then
-            r=`echo "$r" | tr "\n" "-"`
-            r=${r%%-*} && r=${r#*/} && r="/$r"
-            ndnsec-set-default $r
-        fi
-    fi
 }
 
 prepare_for_test() {
     echo "Start test log on remote hub" >$testLog
     echo "Start nfd log on remote hub" >$nfdLog
 
-    LOG "Create hub identity as the default identity"
-    defaultIdentity=$(ndnsec-get-default)
-    ndnsec-key-gen $hubIdentity | ndnsec-cert-install - >>$testLog 2>&1
-
     LOG "create nfd conf file with localhop_security section specified for test"
     [[ ! -f $systemNfdConf ]] && LOG "can not find nfd config file" && exit 1
 
diff --git a/test_auto_prefix_propagate/auto-prefix-propagate-test.sh b/test_auto_prefix_propagate/auto-prefix-propagate-test.sh
index eb7e8db..6f62782 100755
--- a/test_auto_prefix_propagate/auto-prefix-propagate-test.sh
+++ b/test_auto_prefix_propagate/auto-prefix-propagate-test.sh
@@ -7,6 +7,7 @@
 hostSh=A.sh
 hubSh=B.sh
 
+[[ -d $logDir ]] || mkdir -p $logDir
 echo "TEST AUTOMATIC PREFIX PROPAGATE START" > $testLog
 
 LOG () {
@@ -23,9 +24,8 @@
 
 set_hub_trust_anchor () {
     LOG "set the trust anchor to $1 on the hub."
-    anchor=$(sh $hostSh -a $1)
-    echo $anchor > anchor.cert
-    run_scp_to_hub anchor.cert && rm anchor.cert
+    certFile=$(sh $hostSh -a $1)
+    run_scp_to_hub $certFile
 }
 
 run_host_ping_server() {
@@ -40,7 +40,6 @@
     cat nfd.log test.log >> $testLog
 
     bash $hostSh -c && run_hub_cmd "cd $workDir && bash $hubSh -c"
-    run_hub_cmd "[[ -d $workDir ]] && sudo rm -rf $workDir"
     rm *.log
 
     [[ $# -gt 0 ]] && LOG "$1" && exit 1 || exit 0
@@ -76,14 +75,14 @@
     inspect_hub_rib_exist /Z/A "2: route of /Z/A does not exist, but it should exist because \
 automatic prefix propagation is active (/localhop/nfd prefix has been registered), Z/A/G is \
 present in local RIB and /Z/A has been configured as an identity in NFD's keychain."
-    inspect_hub_none /Z/A/G "2: route of /Z/A/G exists, but it should not exist because \
+    inspect_hub_rib_none /Z/A/G "2: route of /Z/A/G exists, but it should not exist because \
 /Z/A is shorter and should be adopted for propagation."
 
     LOG "run test case: 3"
     run_host_ping_server ndn:/Z/A/H && p2=$! && sleep $defer_time
     inspect_hub_rib_exist /Z/A "3: route of /Z/A does not exist, but it should exist because \
 /Z/A has already been propagated."
-    inspect_hub_none /Z/A/H "3: route of /Z/A/H exists, but it should not exist because \
+    inspect_hub_rib_none /Z/A/H "3: route of /Z/A/H exists, but it should not exist because \
 /Z/A is shorter and should be adopted for propagation."
 
     LOG "run test case: 4"