aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore1
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml7
-rwxr-xr-xtest/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh50
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml11
-rw-r--r--test/mocks/pnfsimulator/docker-compose.yml3
-rw-r--r--test/mocks/pnfsimulator/json_schema/input_validator.json12
-rw-r--r--test/mocks/pnfsimulator/netopeer_tls_cfg/building.data10
-rw-r--r--test/mocks/pnfsimulator/netopeer_tls_cfg/building.yang26
-rw-r--r--test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem27
-rw-r--r--test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem.pub9
-rwxr-xr-xtest/mocks/pnfsimulator/netopeer_tls_cfg/update_tls.sh28
11 files changed, 163 insertions, 21 deletions
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore b/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore
new file mode 100644
index 000000000..bd6c5bed8
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore
@@ -0,0 +1 @@
+files/onap/*
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml b/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
index 4d2d32984..466ca5642 100644
--- a/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
@@ -8,7 +8,7 @@ services:
ports:
- "1022:22"
volumes:
- - ./files/onap/:/home/onap/
+ - ./files/onap/sftp/:/home/onap/
restart: on-failure
command: onap:pano:1001
@@ -30,10 +30,7 @@ services:
- ./tls/dfc.crt:/etc/ssl/private/dfc.crt:ro
- ./configuration/vsftpd_ssl.conf:/etc/vsftpd_ssl.conf:ro
- - ./files/onap/0.5MB.tar.gz:/srv/0.5MB.tar.gz:ro
- - ./files/onap/1MB.tar.gz:/srv/1MB.tar.gz:ro
- - ./files/onap/5MB.tar.gz:/srv/5MB.tar.gz:ro
- - ./files/onap/10MB.tar.gz:/srv/10MB.tar.gz:ro
+ - ./files/onap/ftps/:/srv/
restart: on-failure
command: vsftpd /etc/vsftpd_ssl.conf
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh b/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
index 76f333409..f1146a61e 100755
--- a/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
@@ -1,10 +1,50 @@
#!/bin/bash
+# EXAMPLE: Run test case TC2 using the command "./prepare.sh TC2"
+MAIN_DIRECTORY=./files/onap
+TEST_FILE=./test_cases.yml
+TEST=$1
+echo "Generating files for test case:" "$TEST"
-mkdir -p files/onap
+sf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'size_files')
+sf=${sf//*size_files: /}
+sf_array=($sf)
+echo "size_files=""$sf"
-dd if=/dev/urandom of=./files/onap/0.5MB.tar.gz bs=1k count=512
-dd if=/dev/urandom of=./files/onap/1MB.tar.gz bs=1M count=1
-dd if=/dev/urandom of=./files/onap/5MB.tar.gz bs=1M count=5
-dd if=/dev/urandom of=./files/onap/10MB.tar.gz bs=1M count=10
+nf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'number_files')
+nf=${nf//*number_files: /}
+nf_array=($nf)
+echo "number_files=""$nf"
+
+df=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'directory_files')
+df=${df//*directory_files: /}
+df_array=($df)
+echo "directory_files=""$df"
+
+rm -rf $MAIN_DIRECTORY/*
+if [ "${#sf_array[@]}" = "${#nf_array[@]}" ] && [ "${#nf_array[@]}" = "${#df_array[@]}" ];
+then
+ N_ELEMENTS=${#df_array[@]}
+ for ((n=0;n<$N_ELEMENTS;n++))
+ do
+ # Create directory
+ DIRECTORY=$MAIN_DIRECTORY/${df_array[$n]}
+ mkdir -p "$DIRECTORY"
+
+ # Create original file
+ FILE_SIZE=${sf_array[$n]}
+ FILE_NAME=$FILE_SIZE"MB.tar.gz"
+ dd if=/dev/urandom of=$DIRECTORY/$FILE_NAME bs=1k count=$(echo $FILE_SIZE*1000/1 | bc)
+
+ # Create symlinks
+ N_SYMLINKS=${nf_array[$n]}-1
+ for ((l=1;l<=$N_SYMLINKS;l++))
+ do
+ SYMLINK_NAME=$FILE_SIZE"MB_"$l".tar.gz"
+ ln -s ./$FILE_NAME $DIRECTORY/$SYMLINK_NAME
+ done
+ done
+else
+echo "ERROR: The number of parameters in size_files, number_files, and directory_files must be equal!"
+fi
sudo chown root:root ./configuration/vsftpd_ssl.conf
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml b/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml
new file mode 100644
index 000000000..8dba11479
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml
@@ -0,0 +1,11 @@
+# EXAMPLE: TC1 generates (i) 10 files of 1 MB in ftps directory,
+# (ii) 30 files of 5 MB in sftp directory, and (iii) 10 files of 10 MB in sftp directory
+TC1:
+ size_files: 1 5 10
+ number_files: 10 30 10
+ directory_files: ftps sftp sftp
+
+TC2:
+ size_files: 0.5 1 5
+ number_files: 2 3 1
+ directory_files: ftps ftps sftp
diff --git a/test/mocks/pnfsimulator/docker-compose.yml b/test/mocks/pnfsimulator/docker-compose.yml
index 52ded3574..0a0860d0f 100644
--- a/test/mocks/pnfsimulator/docker-compose.yml
+++ b/test/mocks/pnfsimulator/docker-compose.yml
@@ -20,8 +20,10 @@ services:
image: sysrepo/sysrepo-netopeer2:latest
ports:
- "830:830"
+ - "6513:6513"
volumes:
- ./netconf:/netconf
+ - ./netopeer_tls_cfg:/netopeer_tls_cfg
env_file:
- ./config/netconf.env
restart: on-failure
@@ -29,6 +31,7 @@ services:
- sftp-server
- ftpes-server-pure-ftpd
- ftpes-server-vsftpd
+ command: bash -c "/netopeer_tls_cfg/update_tls.sh"
sftp-server:
container_name: sftp-server
diff --git a/test/mocks/pnfsimulator/json_schema/input_validator.json b/test/mocks/pnfsimulator/json_schema/input_validator.json
index 4e75e0adc..13ce589ab 100644
--- a/test/mocks/pnfsimulator/json_schema/input_validator.json
+++ b/test/mocks/pnfsimulator/json_schema/input_validator.json
@@ -79,17 +79,7 @@
"unitType": {
"type": "string"
}
- },
- "required": [
- "serialNumber",
- "vendorName",
- "oamV4IpAddress",
- "oamV6IpAddress",
- "unitFamily",
- "modelNumber",
- "softwareVersion",
- "unitType"
- ]
+ }
},
"notificationParams": {
"type": "object",
diff --git a/test/mocks/pnfsimulator/netopeer_tls_cfg/building.data b/test/mocks/pnfsimulator/netopeer_tls_cfg/building.data
new file mode 100644
index 000000000..42e811b2c
--- /dev/null
+++ b/test/mocks/pnfsimulator/netopeer_tls_cfg/building.data
@@ -0,0 +1,10 @@
+{
+ "building:rooms": {
+ "room": [
+ {
+ "room-number": 3,
+ "size": 3
+ }
+ ]
+ }
+}
diff --git a/test/mocks/pnfsimulator/netopeer_tls_cfg/building.yang b/test/mocks/pnfsimulator/netopeer_tls_cfg/building.yang
new file mode 100644
index 000000000..9afe9721e
--- /dev/null
+++ b/test/mocks/pnfsimulator/netopeer_tls_cfg/building.yang
@@ -0,0 +1,26 @@
+module building {
+ yang-version 1.1;
+ namespace "urn:building:test";
+
+ prefix bld;
+
+ organization "building";
+ contact "my buildig address";
+ description "yang model for building";
+ revision "2018-02-13"{
+ description "initial version";
+ }
+
+ container rooms{
+ list room{
+ key room-number;
+ leaf room-number{
+ type uint16;
+ }
+ leaf size {
+ type uint32;
+ }
+ }
+
+ }
+}
diff --git a/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem b/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem
new file mode 100644
index 000000000..d61c77bdf
--- /dev/null
+++ b/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAsdI1TBjzX1PgQXFuPCw5/kQwU7qkrhirMcFAXhI8EoXepPa9
+fKAVuMjHW32P6nNzDpnhFe0YGdNloIEN3hJJ87cVOqj4o7zZMbq3zVG2L8As7MTA
+8tYXm2fSC/0rIxxRRemcGUXM0q+4LEACjZj2pOKonaivF5VbhgNjPCO1Jj/TamUc
+0aViE577C9L9EiObGM+bGbabWk/KWKLsvxUc+sKZXaJ7psTVgpggJAkUszlmwOQg
+FiMSR53E9/CAkQYhzGVCmH44Vs6Hzs3RZjOTbce4wr4ongiA5LbPeSNSCFjy9loK
+paE1rtOjkNBVdiNPCQTmLuODXUTKgkeL+9v/OwIDAQABAoIBAG/4MG1JbL4C/7vV
+pBcpth7Aaznd1eJ2UB4VVOWnT8JOH2L6p1h5KRRhAP9AMkXsCnAQPyZiVAG3FlAZ
+01SZaY2YJDr6uQ3JVW4155TWtgSdWux//Ass+lJ17lJ0SRxjsV13ez6CsDWeRjc+
+2xy0S+KJgqk71XzhJG9fZLYyuddp3U/i3xFPUAcQM9xXKxcaD7g6LJf+a9pt6rim
+Eqq/pjJxDgTsRLARsazYuxrlOB445mvnLiYhOf2/MvI80jIUKaj8BeAhg49UIg/k
+mIh0xdevkcxBFer/BjBjscWaFjx14D6nkFMw7vtCum5KfalLN2edZKAzByOudGD4
+5KnRp3ECgYEA6vnSoNGg9Do80JOpXRGYWhcR1lIDO5yRW5rVagncCcW5Pn/GMtNd
+x2q6k1ks8mXKR9CxZrxZGqeYObZ9a/5SLih7ZkpiVWXG8ZiBIPhP6lnwm5OeIqLa
+hr0BYWcRfrGg1phj5uySZgsVBE+D8jH42O9ccdvrWv1OiryAHfKIcwMCgYEAwbs+
+HfQtvHOQXSYNhtOeA7IetkGy3cKVg2oILNcROvI96hS0MZKt1Rko0UAapx96eCIr
+el7vfdT0eUzNqt2wTKp1zmiG+SnX3fMDJNzMwu/jb/b4wQ20IHWNDnqcqTUVRUnL
+iksLFoHbTxsN5NpEQExcSt/zzP4qi1W2Bmo18WkCgYEAnhrk16LVux9ohiulHONW
+8N9u+BeM51JtGAcxrDzgGo85Gs2czdwc0K6GxdiN/rfxCKtqgqcfCWlVaxfYgo7I
+OxiwF17blXx7BVrJICcUlqpX1Ebac5HCmkCYqjJQuj/I6jv1lI7/3rt8M79RF+j5
++PXt7Qq97SZd78nwJrZni4MCgYAiPjZ8lOyAouyhilhZvI3xmUpUbMhw6jQDRnqr
+clhZUvgeqAoxuPuA7zGHywzq/WVoVqHYv28Vjs6noiu4R/chlf+8vD0fTYYadRnZ
+Ki4HRt+sqrrNZN6x3hVQudt3DSr1VFXl293Z3JonIWETUoE93EFz+qHdWg+rETtb
+ZuqiAQKBgD+HI/syLECyO8UynuEaDD7qPl87PJ/CmZLMxa2/ZZUjhaXAW7CJMaS6
+9PIzsLk33y3O4Qer0wx/tEdfnxMTBJrgGt/lFFdAKhSJroZ45l5apiavg1oZYp89
+jSd0lVxWSmrBjBZLnqOl336gzaBVkBD5ND+XUPdR1UuVQExJlem4
+-----END RSA PRIVATE KEY-----
diff --git a/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem.pub b/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem.pub
new file mode 100644
index 000000000..9ccec4a0c
--- /dev/null
+++ b/test/mocks/pnfsimulator/netopeer_tls_cfg/test_server_key.pem.pub
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsdI1TBjzX1PgQXFuPCw5
+/kQwU7qkrhirMcFAXhI8EoXepPa9fKAVuMjHW32P6nNzDpnhFe0YGdNloIEN3hJJ
+87cVOqj4o7zZMbq3zVG2L8As7MTA8tYXm2fSC/0rIxxRRemcGUXM0q+4LEACjZj2
+pOKonaivF5VbhgNjPCO1Jj/TamUc0aViE577C9L9EiObGM+bGbabWk/KWKLsvxUc
++sKZXaJ7psTVgpggJAkUszlmwOQgFiMSR53E9/CAkQYhzGVCmH44Vs6Hzs3RZjOT
+bce4wr4ongiA5LbPeSNSCFjy9loKpaE1rtOjkNBVdiNPCQTmLuODXUTKgkeL+9v/
+OwIDAQAB
+-----END PUBLIC KEY-----
diff --git a/test/mocks/pnfsimulator/netopeer_tls_cfg/update_tls.sh b/test/mocks/pnfsimulator/netopeer_tls_cfg/update_tls.sh
new file mode 100755
index 000000000..30be458c6
--- /dev/null
+++ b/test/mocks/pnfsimulator/netopeer_tls_cfg/update_tls.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+NETOPEER_CONFIG_PATH='/opt/dev/Netopeer2/server/configuration'
+MOUNT_PATH='/netopeer_tls_cfg'
+KEY_PATH='/usr/local/etc/keystored/keys'
+SUBSCRIBE_APP_PATH='/opt/dev/sysrepo/build/examples/application_changes_example'
+
+# This function uploads test_data and model into netopeer2 server
+upload_yang_data_model()
+{
+ sysrepoctl -i -g $MOUNT_PATH/building.yang
+ $SUBSCRIBE_APP_PATH building > /dev/null &
+ sysrepocfg --datastore=running --format=json building --import=$MOUNT_PATH/building.data
+}
+
+# This function configures server/trusted certificates into Netopeer
+configure_tls()
+{
+ sed -i "s/>test</>netconf</g" $NETOPEER_CONFIG_PATH/tls_listen.xml
+ sysrepocfg --datastore=running --format=xml ietf-keystore --merge=$NETOPEER_CONFIG_PATH/load_server_certs.xml
+ sysrepocfg --datastore=running --format=xml ietf-netconf-server --merge=$NETOPEER_CONFIG_PATH/tls_listen.xml
+}
+
+cp $MOUNT_PATH/test_server_key.pem $KEY_PATH
+cp $MOUNT_PATH/test_server_key.pem.pub $KEY_PATH
+configure_tls
+upload_yang_data_model
+