4 if expr "$(sw_vers -buildVersion)" : "1[2-9].*[A-Z]" >/dev
/null
; then
6 # only or SULionDuchess or newer
7 elif expr "$(sw_vers -buildVersion)" : "11.*[D-Z]" >/dev
/null
; then
16 t
=$(mktemp -d /tmp/csXXXXXX)
21 echo "[BEGIN] ${test}"
24 "$@" > $t/outfile.txt
2>&1
26 [ $res != 0 ] && res
=1 #normalize
28 if expr "$test" : "fail" > /dev
/null
; then
35 if [ $res = $exp ]; then
40 fails
=$(expr $fails + 1)
45 runTest isroot
test $UID = 0
46 runTest disable
-tests spctl
--master-disable
47 runTest disable
-check eval "spctl --status | grep disable > /dev/null"
48 runTest
enable-tests spctl
--master-enable
49 runTest
enable-check eval "spctl --status | grep enable >/dev/null"
51 runTest
enable-tests spctl
--test-devid-enable
52 runTest
enable-check eval "spctl --test-devid-status | grep enable >/dev/null"
55 runTest fail
-exec-ls spctl
-a -t exec /bin
/ls
56 runTest fail
-open-txt spctl
-a -t open
/usr
/local
/OpenSourceLicenses
/xar.txt
57 runTest fail
-open-pdf spctl
-a -t open
/usr
/share
//cups
/ipptool
/testfile.pdf
64 cp -r "$2" ${t}/"${b}"
65 codesign
-s - -f ${t}/"${b}" > /dev
/null
2>&1 || exit 1
70 selfsign lsbin
/bin
/ls
71 selfsign sysprefs
/Applications
/System\ Preferences.app
73 runTest unpack
-caspian-tests tar Cxf
$t /AppleInternal
/CoreOS
/codesign_tests
/caspian
-tests.
tar.gz
74 runTest unpack
-caspian-test-apple-script tar Cxvf
$t /AppleInternal
/CoreOS
/codesign_tests
/broken
-AppleScript-app.tgz
76 ct
="$t/caspian-tests/tests"
78 runTest fail
-exec-ls spctl
-a -t exec $lsbin
79 runTest fail
-exec-ls spctl
-a -t exec "$sysprefs"
81 runTest disable
-tests2 spctl
--master-disable
82 runTest disable
-check2 eval "spctl --status | grep disable > /dev/null"
84 runTest
exec-ls spctl
-a -t exec $lsbin
85 runTest
exec-ls spctl
-a -t exec "$sysprefs"
87 runTest
enable-tests3 spctl
--master-enable
88 runTest
enable-check3 eval "spctl --status | grep enable > /dev/null"
90 xardir
=/AppleInternal
/CoreOS
/codesign_tests
/xar
92 caspianvalid
="OSUpgrade-XBS Nothing-valid Nothing-noocsp Nothing-expired"
93 caspianinvalid
="Nothing-adhoc Nothing-revoked Nothing-unsigned"
94 applescriptbroken
="Broken.app"
96 runTest fail
-install-no-existant-file spctl
-a -t install ${xardir}/really
-i-dont-exists.pkg
98 for a
in Nothing
-bnisigned ; do
99 runTest
install-${a} spctl
-a -t install ${xardir}/${a}.pkg
101 for a
in old
-sig new
-sig ; do
102 runTest fail
-install-${a} spctl
-a -t install ${xardir}/${a}.pkg
104 for a
in ${caspianvalid}; do
105 runTest
install-${a} spctl
-a -t install ${ct}/${a}.pkg
107 for a
in ${caspianinvalid}; do
108 runTest fail
-install-${a} spctl
-a -t install ${ct}/${a}.pkg
110 for a
in ${applescriptbroken}; do
111 runTest fail
-install-${a} spctl
-a -t install ${t}/${a}.pkg
114 runTest disable
-tests3 spctl
--master-disable
115 runTest disable
-check3 eval "spctl --status | grep disable > /dev/null"
117 for a
in Nothing
-bnisigned; do
118 runTest
install-${a} spctl
-a -t install ${xardir}/${a}.pkg
120 for a
in ${caspianvalid} ${caspianinvalid}; do
121 runTest
install-master-disabled-${a} spctl
-a -t install ${xardir}/${a}.pkg
125 # check path based --add/--disable/--remove
128 runTest
enable-tests4 spctl
--master-enable
129 runTest
enable-check4 eval "spctl --status | grep enable > /dev/null"
131 runTest copyTextEdit
cp -R /Applications
/TextEdit.app
$t/MyTextEdit.app
132 runTest codesignMyTextEdit codesign
-f -s - $t/MyTextEdit.app
134 runTest fail
-run-MyTextEdit1 spctl
-a -t exec $t/MyTextEdit.app
135 runTest add
-MyTextEdit spctl
--add --path $t/MyTextEdit.app
136 runTest assess
-MyTextEdit2 spctl
-a -t exec $t/MyTextEdit.app
138 runTest disable
-MyTextEdit spctl
--disable --path $t/MyTextEdit.app
139 runTest fail
-assess-MyTextEdit3 spctl
-a -t exec $t/MyTextEdit.app
141 runTest
enable-MyTextEdit spctl
--enable --path $t/MyTextEdit.app
142 runTest assess
-MyTextEdit4 spctl
-a -t exec $t/MyTextEdit.app
144 runTest remove
-MyTextEdit spctl
--remove --path $t/MyTextEdit.app
145 runTest fail
-assess-MyTextEdit5 spctl
-a -t exec $t/MyTextEdit.app
147 runTest disable
-tests4 spctl
--master-disable
148 runTest disable
-check4 eval "spctl --status | grep disable > /dev/null"
150 runTest assess
-MyTextEdit6 spctl
-a -t exec $t/MyTextEdit.app
153 # check label based --add/--disable/--remove
156 runTest
enable-tests7 spctl
--master-enable
157 runTest
enable-check7 eval "spctl --status | grep enable > /dev/null"
159 runTest fail
-run-MyTextEdit1 spctl
-a -t exec $t/MyTextEdit.app
160 runTest add
-MyTextEdit spctl
--add --label CaspianTest
--path $t/MyTextEdit.app
161 runTest assess
-MyTextEdit2 spctl
-a -t exec $t/MyTextEdit.app
163 runTest disable
-MyTextEdit spctl
--disable --label CaspianTest
164 runTest fail
-assess-MyTextEdit3 spctl
-a -t exec $t/MyTextEdit.app
166 runTest
enable-MyTextEdit spctl
--enable --label CaspianTest
167 runTest assess
-MyTextEdit4 spctl
-a -t exec $t/MyTextEdit.app
169 runTest remove
-MyTextEdit spctl
--remove --label CaspianTest
170 runTest fail
-assess-MyTextEdit5 spctl
-a -t exec $t/MyTextEdit.app
172 runTest disable
-tests8 spctl
--master-disable
173 runTest disable
-check8 eval "spctl --status | grep disable > /dev/null"
175 runTest assess
-MyTextEdit6 spctl
-a -t exec $t/MyTextEdit.app
178 # check adding certificate based --add/--disable/--remove
181 runTest
enable-tests9 spctl
--master-enable
182 runTest
enable-check9 eval "spctl --status | grep enable > /dev/null"
184 # clear out existing rules
185 spctl
--remove --label CapsianTest
-apple-root > /dev
/null
2>&1
187 runTest add
-add-anchor-by-label spctl
--add --label CapsianTest
-apple-root --anchor 611E5B662C593A08FF58D14AE22452D198DF6C60
188 runTest add
-remove-by-label spctl
--remove --label CapsianTest
-apple-root
190 runTest disable
-tests10 spctl
--master-disable
191 runTest disable
-check10 eval "spctl --status | grep disable > /dev/null"
194 # check devid is still revoked while caspian is disabled
197 runTest fail
-0-hello-revoked spctl
-a -t exec ${ct}/hello
-revoked.app
198 runTest
0-hello-expired spctl
-a -t exec ${ct}/hello
-expired.app
201 # check enabled w/o devid
204 runTest
enable-tests11 spctl
--master-enable
205 runTest
enable-check11 eval "spctl --status | grep enable > /dev/null"
207 runTest fail
-1-hello-revoked spctl
-a -t exec ${ct}/hello
-revoked.app
208 #runTest fail-1-hello-expired spctl -a -t exec ${ct}/hello-expired #### failes because of broken ocsp
214 runTest
enable-tests11 spctl
--test-devid-enable
215 runTest
enable-check11 eval "spctl --test-devid-status | grep enable > /dev/null"
217 runTest fail
-1id-hello-revoked spctl
-a -t exec ${ct}/hello
-revoked.app
218 runTest
1id
-hello-expired spctl
-a -t exec ${ct}/hello
-expired.app
224 runTest disable
-tests11 spctl
--master-disable
225 runTest disable
-check11 eval "spctl --status | grep disable > /dev/null"
228 # Check that Capsian is on/off by default
231 case $(sw_vers -buildVersion) in
232 11*) status
=disable
;;
233 12A154
*) status
=disable
;; ## was disabled for ZinDP2
237 rm -f /var
/db
/.sp_visible
/var
/db
/SystemPolicy
-prefs.plist
238 notifyutil
-p com.apple.security.assessment.masterswitch
240 runTest
enable-check11 eval "spctl --status | grep $status > /dev/null"
243 # check that --list works
246 case $(sw_vers -buildVersion) in
248 12A178
*) ;; #disable in dp3
251 runTest checkSystemRule
eval "spctl --list | grep 'P0 allow execute'"
252 runTest addTextEdit spctl
--add --path /Applications
/TextEdit.app
253 runTest checkTextEditInList
eval "spctl --list | grep TextEdit"
254 runTest removeTextEdit spctl
--remove --path /Applications
/TextEdit.app
256 runTest checkListRule2 spctl
--list --rule 2
263 # Misc regression cases
266 runTest fail
-evil-itunes spctl
-a -t exec $ct/evil
-itunes.app
267 runTest fail
-finderinfo codesign
-fs- $ct/ls-finderinfo
268 runTest fail
-resourcefork codesign
-fs- $ct/cp-resourcefork
269 runTest fail
-finderinfo-app codesign
-fs- $ct/HelloCaspian
-finderinfo.app
270 runTest fail
-resourcefork-app codesign
-fs- $ct/HelloCaspian
-resourcefork.app
271 runTest override
-resourcefork-app codesign
-fs- --no-strict $ct/HelloCaspian
-resourcefork.app
280 if [ $fails != 0 ] ; then
281 echo "$fails caspian tests failed"
284 echo "all caspian tests passed"