Update wrt-security_0.0.42
[framework/web/wrt-security.git] / tests / wrt-tests-security-all.sh
1 #!/bin/sh
2
3 #####################################################################
4 # Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
5 #
6 #    Licensed under the Apache License, Version 2.0 (the "License");
7 #    you may not use this file except in compliance with the License.
8 #    You may obtain a copy of the License at
9 #
10 #        http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #    Unless required by applicable law or agreed to in writing, software
13 #    distributed under the License is distributed on an "AS IS" BASIS,
14 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #    See the License for the specific language governing permissions and
16 #    limitations under the License.
17 #####################################################################
18
19 #####################################################################
20 # author: Tomasz Swierczek
21 # email: t.swierczek@samsung.com
22 # description: Simple script that checks prerequisites and fires security tests
23 #####################################################################
24
25
26 # Print error and exit
27 error(){
28     echo "[ERROR]" $1
29     exit 1
30 }
31
32 # Checks for one package (dpkg)
33 check_network_access(){
34   echo "--- Checking for network access..."
35   ping -c 2 www.google.com > /dev/null || error 'Network not accessible'
36   echo 'Network access OK'
37 }
38
39 # Date sanity check - checks year (common error: after flashing, date is sth like 1970 or so)
40 check_date(){
41   echo "--- Checkig date..."
42   date
43   openssl verify -CAfile /opt/apps/widget/tests/vcore_certs/cacert.pem   /opt/apps/widget/tests/vcore_certs/respcert.pem 2>/dev/null | grep OK 1>/dev/null || error 'Date not set properly'
44   echo 'Date OK'
45 }
46
47 check_network_access
48 check_date
49
50 echo "--- Starting OpenSSL OCSP test server on target..."
51
52 wrt-tests-vcore-ocsp-server.sh &
53 sleep 3 # needed for ocsp server to work properly
54
55 echo "--- Starting tests..."
56 cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
57 cp /usr/etc/ace/TizenPolicy.xml /usr/etc/ace/TizenPolicy.xml.bk
58 cp /usr/etc/ace/WAC2.0Policy-test.xml /usr/etc/ace/WAC2.0Policy.xml
59 cp /usr/etc/ace/TizenPolicy-test.xml /usr/etc/ace/TizenPolicy.xml
60 wrt-tests-ace --output=text
61 cp /usr/etc/ace/WAC2.0Policy.xml.bk /usr/etc/ace/WAC2.0Policy.xml
62 cp /usr/etc/ace/TizenPolicy.xml.bk /usr/etc/ace/TizenPolicy.xml
63 wrt_security_create_clean_db.sh
64 wrt-tests-ace-client --output=text
65 wrt_security_create_clean_db.sh
66 wrt-tests-ace-settings --output=text
67 wrt_security_create_clean_db.sh
68 cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
69 cp /usr/etc/ace/ace-install-api-demo-policy.xml /usr/etc/ace/WAC2.0Policy.xml
70 wrt_security_change_policy.sh
71 wrt-tests-ace-install --output=text
72 cp /usr/etc/ace/WAC2.0Policy.xml.bk /usr/etc/ace/WAC2.0Policy.xml
73 wrt_security_create_clean_db.sh
74 cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
75 cp /usr/etc/ace/ipc-tests-demo.xml /usr/etc/ace/WAC2.0Policy.xml
76 wrt_security_change_policy.sh
77 wrt-tests-security-daemon --output=text
78 cp /usr/etc/ace/WAC2.0Policy.xml.bk /usr/etc/ace/WAC2.0Policy.xml
79 wrt_security_create_clean_db.sh
80 wrt-tests-vcore --output=text
81 pkill -9 wrt-secur # security daemon needs to be killed, as database connections need to be changed (SQLite files are changed!)
82
83 echo "--- Done."
84
85 pkill -9 openssl 2> /dev/null # to kill openssl ocsp server in case it was not killed