Added libprivilege-control tests.
[platform/core/test/security-tests.git] / tests / security-tests.sh
1 #!/bin/sh
2
3 #####################################################################
4 # Copyright (c) 2012 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 #testing internet access and date on the target
20 error(){
21     echo "[ERROR]" $1
22     exit 1
23 }
24
25 check_network_access(){
26   echo "--- Checking for network access..."
27   ping -c 2 www.google.com > /dev/null || error 'Network not accessible'
28   echo 'Network access OK'
29 }
30
31 check_date(){
32   echo "--- Checkig date..."
33   date
34   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'
35   echo 'Date OK'
36 }
37
38 kill_daemon(){
39     echo "--- Killing daemon"
40     wrt_security_create_clean_db.sh
41     pkill -9 security-ser && sleep 3
42     echo "--- Done"
43 }
44
45
46 echo "### Starting tests ######################################################"
47
48 case $1 in
49
50 "capi")
51     echo "========================================================================="
52     echo "CAPI"
53     echo
54     #check network and date
55     check_network_access
56     check_date
57     #test binary execution
58     cert-svc-tests-capi $2 $3
59     ;;
60
61 "pkcs")
62     echo "========================================================================="
63     echo "PKCS12"
64     echo
65     #test binary execution
66     cert-svc-tests-pkcs12 $2 $3
67     ;;
68
69 "vcore")
70     echo "========================================================================="
71     echo "VCORE"
72     echo
73     #check network and date
74     check_network_access
75     check_date
76     #environment setup
77     cert-svc-tests-vcore-ocsp-server.sh &
78     #test binary execution
79     cert-svc-tests-vcore $2 $3
80     ;;
81
82 "smack")
83     echo "========================================================================="
84     echo "SMACK"
85     echo
86     #test binary execution
87     libsmack-test $2 $3
88     ;;
89
90 "pc")
91     echo "========================================================================="
92     echo "PRIVILEGE CONTROL"
93     echo
94     #test binary execution
95     libprivilege-control-test $2 $3
96     ;;
97
98 "ace")
99     echo "========================================================================="
100     echo "ACE"
101     echo
102     #environment setup
103     cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
104     cp /usr/etc/ace/TizenPolicy.xml /usr/etc/ace/TizenPolicy.xml.bk
105     cp /usr/etc/ace/WAC2.0Policy-test.xml /usr/etc/ace/WAC2.0Policy.xml
106     cp /usr/etc/ace/TizenPolicy-test.xml /usr/etc/ace/TizenPolicy.xml
107     kill_daemon
108     #test binary execution
109     wrt-tests-ace $2 $3
110     ;;
111
112 "ace-client")
113     echo "========================================================================="
114     echo "ACE-CLIENT"
115     echo
116     #environment setup
117     cp /usr/etc/ace/WAC2.0Policy.xml.bk /usr/etc/ace/WAC2.0Policy.xml
118     cp /usr/etc/ace/TizenPolicy.xml.bk /usr/etc/ace/TizenPolicy.xml
119     kill_daemon
120     #test binary execution
121     wrt-tests-ace-client $2 $3
122     ;;
123
124 "ace-settings")
125     echo "========================================================================="
126     echo "ACE-SETTINGS"
127     echo
128     #environment setup
129     kill_daemon
130     #test binary execution
131     wrt-tests-ace-settings $2 $3
132     ;;
133
134 "ace-install")
135     echo "========================================================================="
136     echo "ACE-INSTALL"
137     echo
138     #environment setup
139     kill_daemon
140     cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
141     cp /usr/etc/ace/ace-install-api-demo-policy.xml /usr/etc/ace/WAC2.0Policy.xml
142     wrt_security_change_policy.sh
143     #test binary execution
144     wrt-tests-ace-install $2 $3
145     ;;
146
147 "security-daemon")
148     echo "========================================================================="
149     echo "SECURITY-DAEMON"
150     echo
151     #environment setup
152     cp /usr/etc/ace/WAC2.0Policy.xml.bk /usr/etc/ace/WAC2.0Policy.xml
153     kill_daemon
154     cp /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.xml.bk
155     cp /usr/etc/ace/ipc-tests-demo.xml /usr/etc/ace/WAC2.0Policy.xml
156     wrt_security_change_policy.sh
157     #test binary execution
158     wrt-tests-security-daemon $2 $3
159     ;;
160
161 *)
162     echo "Correct using:"
163     echo "    security_test.sh <module> <args_for_module>"
164     echo
165     echo "modules: ace, ace-client, ace-settings, ace-install,"
166     echo "         security-daemon, vcore, capi, pkcs, smack"
167     ;;
168
169 esac
170
171 #clean up
172 pkill -9 wrt-secur # security daemon needs to be killed, as database connections need to be changed (SQLite files are changed!)
173
174 echo "### Tests done ##########################################################"