-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-6672] Moved fvt script to right directory
The passwordsInLog_test.sh fvt script was checked in to wrong directory. This change is to move it to the right directory scripts/fvt/ Change-Id: I3791e47579c3aa71239db57202ea4525e44523fe Signed-off-by: Anil Ambati <[email protected]>
- Loading branch information
Anil Ambati
committed
Oct 19, 2017
1 parent
2886abd
commit 4edfdd8
Showing
3 changed files
with
83 additions
and
166 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,14 @@ | |
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
function rmConfigFiles() { | ||
rm -rf $TESTDIR/ca-cert.pem \ | ||
$TESTDIR/fabric-ca-server-config.yaml \ | ||
$TESTDIR/fabric-ca-server.db $TESTDIR/msp \ | ||
$TESTDIR/fabric-ca-cert.pem $TESTDIR/fabric_ca \ | ||
$TESTDIR/runFabricCaFvt.yaml | ||
} | ||
|
||
function checkPasswd() { | ||
local pswd="$1" | ||
local Type="$2" | ||
|
@@ -13,21 +21,23 @@ function checkPasswd() { | |
set -f | ||
# Extract password value(s) from logfile | ||
case "$Type" in | ||
user) passwd=$(egrep -o "Pass:[^[:space:]]+" $LOGFILE| awk -F':' '{print $2}') ;; | ||
ldap) passwd=$(egrep -io "ldap.*@" $LOGFILE| awk -v FS=[:@] '{print $(NF-1)}') ;; | ||
mysql) passwd=$(egrep -o "[a-z0-9*]+@tcp" $LOGFILE| awk -v FS=@ '{print $(NF-1)}') ;; | ||
postgres) passwd=$(egrep -o "password=[^ ]+ " $LOGFILE| awk -F '=' '{print $2}') ;; | ||
user) passwd=$(egrep -ao "Pass:[^[:space:]]+" $LOGFILE| awk -F':' '{print $2}') ;; | ||
ldap) passwd=$(egrep -aio "ldap.*@" $LOGFILE| awk -v FS=[:@] '{print $(NF-1)}') ;; | ||
mysql) passwd=$(egrep -ao "[a-z0-9*]+@tcp" $LOGFILE| awk -v FS=@ '{print $(NF-1)}') ;; | ||
postgres) passwd=$(egrep -ao "password=[^ ]+ " $LOGFILE| awk -F '=' '{print $2}') ;; | ||
register) passwd=$(egrep -oar 'Received registration.*Secret[^ ]+' $LOGFILE | awk -F':' '{print $NF}') ;; | ||
intermediateCa) passwd=$(egrep -ao "Enrolling.*Secret:[^ ]+ " $LOGFILE | awk -F':' '{print $NF}') ;; | ||
esac | ||
|
||
# Fail if password is empty | ||
if [[ -z "$passwd" ]] ; then | ||
ErrorMsg "Unable to extract password value(s)" | ||
ErrorMsg "Unable to extract password value(s) for type $Type" | ||
fi | ||
|
||
# Fail if password matches anything other than '*' | ||
for p in $passwd; do | ||
if ! [[ "$p" =~ \*+ ]]; then | ||
ErrorMsg "Passwords were not masked in the log" | ||
ErrorMsg "Password '$passwd' was not masked in the log" | ||
fi | ||
done | ||
|
||
|
@@ -41,44 +51,88 @@ function checkPasswd() { | |
function passWordSub() { | ||
sed -i "/datasource:/ s/\(password=\)[[:alnum:]]\+\(.*\)/\1$PSWD\2/ | ||
s/dc=com:$LDAP_PASSWD/dc=com:$PSWD/ | ||
/enrollment:/ a\ name: user\n secret: $PSWD | ||
s/datasource:\(.*\)mysql@/datasource:\1$PSWD@/" $TESTDIR/runFabricCaFvt.yaml | ||
} | ||
|
||
function testBootstrap() { | ||
> $LOGFILE | ||
# Test using bootstrap ID | ||
fabric-ca-server init -b $USER:$PSWD -d 2>&1 | tee $LOGFILE | ||
test ${PIPESTATUS[0]} -eq 0 && checkPasswd "$PSWD" || ErrorMsg "Init of CA failed" | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/testBootstrap.log | ||
} | ||
|
||
function testCaRegistry() { | ||
> $LOGFILE | ||
# Test using multiple IDs from pre-supplied config file | ||
$SCRIPTDIR/fabric-ca_setup.sh -I -X -n1 -D 2>&1 | tee $LOGFILE | ||
test ${PIPESTATUS[0]} -eq 0 && checkPasswd "$PSWD" || ErrorMsg "Init of CA failed" | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/testCaRegistry.log | ||
} | ||
|
||
function testExternalServers() { | ||
for server in mysql postgres ldap; do | ||
rmConfigFiles | ||
case $server in | ||
ldap) $SCRIPTDIR/fabric-ca_setup.sh -a -I -D > $LOGFILE 2>&1 ;; | ||
*) $SCRIPTDIR/fabric-ca_setup.sh -I -D -d $server > $LOGFILE 2>&1 ;; | ||
esac | ||
passWordSub | ||
$SCRIPTDIR/fabric-ca_setup.sh -D -X -S >> $LOGFILE 2>&1 | ||
test $? -eq 0 && checkPasswd "$PSWD" $server || ErrorMsg "Start of CA failed" | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/test${server}.log | ||
$SCRIPTDIR/fabric-ca_setup.sh -K | ||
done | ||
} | ||
|
||
function testRegister() { | ||
rmConfigFiles | ||
$SCRIPTDIR/fabric-ca_setup.sh -D -X -I -S > $LOGFILE 2>&1 | ||
test $? -eq 0 && checkPasswd "$PSWD" $server || ErrorMsg "Start of CA failed" | ||
enroll | ||
register | ||
checkPasswd "" register | ||
cat $LOGFILE | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/testRegisterGeneratedPswd.log | ||
> $LOGFILE | ||
register "" Testuser2 "" "" "" "" "$PSWD" | ||
checkPasswd "$PSWD" register | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/testRegisterSuppliedPswd.log | ||
} | ||
|
||
function testIntermediateCa() { | ||
FABRIC_CA_SERVER_HOME="$FABRIC_CA_SERVER_HOME/intCa1" | ||
LOGFILE=$TESTDIR/testIntermediateCa.log | ||
fabric-ca-server start --csr.hosts 127.0.0.2 --address 127.0.0.2 --port 7055 -b admin:adminpw $INTTLSOPT \ | ||
-u ${PROTO}intermediateCa1:[email protected]:$CA_DEFAULT_PORT -d > $LOGFILE 2>&1 & | ||
pollServer fabric-ca-server 127.0.0.2 7055 || ErrorMsg "Failed to start intermediate CA" | ||
checkPasswd intermediateCa1pw intermediateCa | ||
cp $LOGFILE $FABRIC_CA_SERVER_HOME/testIntermediateCa.log | ||
} | ||
|
||
### Start Main Test ### | ||
RC=0 | ||
TESTCASE="passwordsInLog" | ||
TESTDIR="/tmp/$TESTCASE" | ||
mkdir -p $TESTDIR | ||
|
||
FABRIC_CA="$GOPATH/src/github.com/hyperledger/fabric-ca" | ||
SCRIPTDIR="$FABRIC_CA/scripts/fvt" | ||
. $SCRIPTDIR/fabric-ca_utils | ||
|
||
export CA_CFG_PATH="$TESTDIR" | ||
export FABRIC_CA_SERVER_HOME="$TESTDIR" | ||
LOGFILE=$FABRIC_CA_SERVER_HOME/log.txt | ||
|
||
USER=administrator | ||
PSWD=thisIs_aLongUniquePasswordWith_aMinisculePossibilityOfBeingDuplicated | ||
|
||
# Test using bootstrap ID | ||
fabric-ca-server init -b $USER:$PSWD -d 2>&1 | tee $LOGFILE | ||
test ${PIPESTATUS[0]} -eq 0 && checkPasswd "$PSWD" || ErrorMsg "Init of CA failed" | ||
|
||
# Test using multiple IDs from pre-supplied config file | ||
$SCRIPTDIR/fabric-ca_setup.sh -R; mkdir -p $TESTDIR | ||
$SCRIPTDIR/fabric-ca_setup.sh -I -X -n1 -D 2>&1 | tee $LOGFILE | ||
test ${PIPESTATUS[0]} -eq 0 && checkPasswd "$PSWD" || ErrorMsg "Init of CA failed" | ||
|
||
for server in ldap mysql postgres; do | ||
$SCRIPTDIR/fabric-ca_setup.sh -R; mkdir -p $TESTDIR | ||
case $server in | ||
ldap) $SCRIPTDIR/fabric-ca_setup.sh -a -I -D > $LOGFILE 2>&1 ;; | ||
*) $SCRIPTDIR/fabric-ca_setup.sh -I -D -d $server 2>&1 > $LOGFILE ;; | ||
esac | ||
passWordSub | ||
$SCRIPTDIR/fabric-ca_setup.sh -S >> $LOGFILE 2>&1 | ||
test ${PIPESTATUS[0]} -eq 0 && checkPasswd "$PSWD" $server || ErrorMsg "Init of CA failed" | ||
done | ||
$SCRIPTDIR/fabric-ca_setup.sh -R | ||
mkdir -p $TESTDIR | ||
setTLS | ||
testBootstrap | ||
testCaRegistry | ||
testExternalServers | ||
testRegister | ||
testIntermediateCa | ||
|
||
CleanUp $RC | ||
exit $RC |