PageRenderTime 55ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/usr/src/suites/security/kmf/tests/kmfcfg/kmfcfg_create_002.ksh

https://bitbucket.org/illumos/illumos-stc
Korn Shell | 404 lines | 307 code | 33 blank | 64 comment | 14 complexity | c5dc84001dbde86abae6f508ec55beb8 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. #! /usr/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. # ident "%Z%%M% %I% %E% SMI"
  27. #
  28. #########################################################################
  29. #
  30. # start __stf_assertion__
  31. #
  32. # ASSERTION: kmfcfg_create_002
  33. #
  34. # DESCRIPTION:
  35. #
  36. # Verify:
  37. # "kmfcfg create" with appropriate options can create policies with
  38. # OCSP verification method.
  39. #
  40. # STRATEGY:
  41. #
  42. # 1) Backup test.xml to test.xml.bak
  43. # 2) Run "kmfcfg create dbfile=test.xml policy=testpolicy" with ocsp
  44. # options and save the output to a temp variable
  45. # 3) Check the return value of command
  46. # 4) Verify the new policy with "kmfcfg list dbfile=test.xml policy=testpolicy"
  47. # 5) Restore the test.xml to the original one
  48. # 6) Repeat 2),3),4),5) for create subcommand with different ocsp options
  49. #
  50. # INTERFACE: kmfcfg
  51. #
  52. # end __stf_assertion__
  53. #
  54. #########################################################################
  55. . ${STF_TOOLS}/include/stf.kshlib
  56. . ${STF_TOOLS}/contrib/include/jnl.kshlib
  57. description() {
  58. cat <<-EOF
  59. Verify:
  60. "kmfcfg create" with appropriate options can create policies with
  61. OCSP verification method.
  62. EOF
  63. }
  64. jnl_assertion "$( description )" "kmfcfg create"
  65. test_db="/var/tmp/test.xml"
  66. cmd="/usr/bin/kmfcfg"
  67. common_options="create dbfile=$test_db policy=testpolicy ignore-trust-anchor=true"
  68. list_options="list dbfile=$test_db policy=testpolicy"
  69. issuer_dn="O=Sun Microsytems Inc., OU=Solaris Qe Ops, L=Beijing, ST=Beijing, \
  70. C=PR, CN=Eddie Luo"
  71. set -A cmd_args \
  72. "ocsp-use-cert-responder=true" \
  73. "ocsp-responder=http://ocsp.verisign.com/ocsp/status" \
  74. "ocsp-responder=http://ocsp.verisign.com/ocsp/status ocsp-proxy=webcache.sfbay:8080" \
  75. "ocsp-use-cert-responder=true ocsp-ignore-response-sign=true" \
  76. "ocsp-use-cert-responder=true ocsp-response-lifetime=12-hour" \
  77. "ocsp-use-cert-responder=true ocsp-responder-cert-name=\"$issuer_dn\" ocsp-responder-cert-serial=0303"
  78. # Back up test.xml
  79. jnl_progress "Backup the original dbfile test.xml"
  80. cp $test_db test.xml.bak
  81. e=$?
  82. if [[ $e -ne 0 ]]; then
  83. jnl_diagnostic "Backup test dbfile" "0" $e "STF_UNRESOLVED"
  84. rm -f test.xml.bak
  85. exit $STF_UNRESOLVED
  86. fi
  87. output=""
  88. ##########################Create cmd_args[0] BEGIN#########################################
  89. jnl_progress "$cmd $common_options ${cmd_args[0]}"
  90. output=$(ksh -c "$cmd $common_options ${cmd_args[0]}")
  91. e=$?
  92. if [[ $e -ne 0 ]]; then
  93. jnl_diagnostic "$cmd $common_options ${cmd_args[0]} $output" 0 $e "STF_FAIL"
  94. jnl_result $STF_FAIL
  95. cp test.xml.bak $test_db
  96. rm -f test.xml.bak
  97. exit $STF_FAIL
  98. fi
  99. jnl_progress "$cmd $list_options"
  100. $cmd $list_options > result.$$
  101. e=$?
  102. if [[ $e -ne 0 ]]; then
  103. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  104. jnl_result $STF_UNRESOLVED
  105. cat result.$$
  106. cp test.xml.bak $test_db
  107. rm -f test.xml.bak
  108. rm -f result.$$
  109. exit $STF_UNRESOLVED
  110. fi
  111. grep 'Use ResponderURI from Certificate: true' result.$$
  112. e=$?
  113. if [[ $e -ne 0 ]]; then
  114. jnl_error "Can't find policy from test.xml"
  115. jnl_result $STF_FAIL
  116. cp test.xml.bak $test_db
  117. rm -f test.xml.bak
  118. rm -f result.$$
  119. exit $STF_FAIL
  120. fi
  121. # Restore test dbfile
  122. cp test.xml.bak $test_db
  123. e=$?
  124. if [[ $e -ne 0 ]]; then
  125. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  126. rm -f test.xml.bak
  127. rm -f result.$$
  128. exit $STF_UNRESOLVED
  129. fi
  130. ##########################Create cmd_args[0] END###########################################
  131. ##########################Create cmd_args[1] BEGIN#########################################
  132. jnl_progress "$cmd $common_options ${cmd_args[1]}"
  133. output=$(ksh -c "$cmd $common_options ${cmd_args[1]}")
  134. e=$?
  135. if [[ $e -ne 0 ]]; then
  136. jnl_diagnostic "$cmd $common_options ${cmd_args[1]} $output" 0 $e "STF_FAIL"
  137. jnl_result $STF_FAIL
  138. cp test.xml.bak $test_db
  139. rm -f test.xml.bak
  140. rm -f result.$$
  141. exit $STF_FAIL
  142. fi
  143. jnl_progress "$cmd $list_options"
  144. $cmd $list_options > result.$$
  145. e=$?
  146. if [[ $e -ne 0 ]]; then
  147. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  148. jnl_result $STF_UNRESOLVED
  149. cp test.xml.bak $test_db
  150. rm -f test.xml.bak
  151. rm -f result.$$
  152. exit $STF_UNRESOLVED
  153. fi
  154. grep 'Responder URI: http://ocsp.verisign.com/ocsp/status' result.$$
  155. e=$?
  156. if [[ $e -ne 0 ]]; then
  157. jnl_error "Can't find policy from test.xml"
  158. jnl_result $STF_FAIL
  159. cp test.xml.bak $test_db
  160. rm -f test.xml.bak
  161. rm -f result.$$
  162. exit $STF_FAIL
  163. fi
  164. # Restore test dbfile
  165. cp test.xml.bak $test_db
  166. e=$?
  167. if [[ $e -ne 0 ]]; then
  168. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  169. rm -f test.xml.bak
  170. rm -f result.$$
  171. exit $STF_UNRESOLVED
  172. fi
  173. ##########################Create cmd_args[1] END###########################################
  174. ##########################Create cmd_args[2] BEGIN#########################################
  175. jnl_progress "$cmd $common_options ${cmd_args[2]}"
  176. output=$(ksh -c "$cmd $common_options ${cmd_args[2]}")
  177. e=$?
  178. if [[ $e -ne 0 ]]; then
  179. jnl_diagnostic "$cmd $common_options ${cmd_args[2]} $output" 0 $e "STF_FAIL"
  180. jnl_result $STF_FAIL
  181. cp test.xml.bak $test_db
  182. rm -f test.xml.bak
  183. rm -f result.$$
  184. exit $STF_FAIL
  185. fi
  186. jnl_progress "$cmd $list_options"
  187. $cmd $list_options > result.$$
  188. e=$?
  189. if [[ $e -ne 0 ]]; then
  190. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  191. jnl_result $STF_UNRESOLVED
  192. cp test.xml.bak $test_db
  193. rm -f test.xml.bak
  194. rm -f result.$$
  195. exit $STF_UNRESOLVED
  196. fi
  197. grep 'Responder URI: http://ocsp.verisign.com/ocsp/status' result.$$ && \
  198. grep 'Proxy: webcache.sfbay:8080' result.$$
  199. e=$?
  200. if [[ $e -ne 0 ]]; then
  201. jnl_error "Can't find policy from test.xml"
  202. jnl_result $STF_FAIL
  203. cp test.xml.bak $test_db
  204. rm -f test.xml.bak
  205. rm -f result.$$
  206. exit $STF_FAIL
  207. fi
  208. # Restore test dbfile
  209. cp test.xml.bak $test_db
  210. e=$?
  211. if [[ $e -ne 0 ]]; then
  212. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  213. rm -f test.xml.bak
  214. rm -f result.$$
  215. exit $STF_UNRESOLVED
  216. fi
  217. ##########################Create cmd_args[2] END###########################################
  218. ##########################Create cmd_args[3] BEGIN#########################################
  219. jnl_progress "$cmd $common_options ${cmd_args[3]}"
  220. output=$(ksh -c "$cmd $common_options ${cmd_args[3]}")
  221. e=$?
  222. if [[ $e -ne 0 ]]; then
  223. jnl_diagnostic "$cmd $common_options ${cmd_args[3]} $output" 0 $e "STF_FAIL"
  224. jnl_result $STF_FAIL
  225. cp test.xml.bak $test_db
  226. rm -f test.xml.bak
  227. rm -f result.$$
  228. exit $STF_FAIL
  229. fi
  230. jnl_progress "$cmd $list_options"
  231. $cmd $list_options > result.$$
  232. e=$?
  233. if [[ $e -ne 0 ]]; then
  234. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  235. jnl_result $STF_UNRESOLVED
  236. cp test.xml.bak $test_db
  237. rm -f test.xml.bak
  238. rm -f result.$$
  239. exit $STF_UNRESOLVED
  240. fi
  241. grep 'Ignore Response signature: true' result.$$
  242. e=$?
  243. if [[ $e -ne 0 ]]; then
  244. jnl_error "Can't find policy from test.xml"
  245. jnl_result $STF_FAIL
  246. cp test.xml.bak $test_db
  247. rm -f test.xml.bak
  248. rm -f result.$$
  249. exit $STF_FAIL
  250. fi
  251. # Restore test dbfile
  252. cp test.xml.bak $test_db
  253. e=$?
  254. if [[ $e -ne 0 ]]; then
  255. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  256. rm -f test.xml.bak
  257. rm -f result.$$
  258. exit $STF_UNRESOLVED
  259. fi
  260. ##########################Create cmd_args[3] END###########################################
  261. ##########################Create cmd_args[4] BEGIN#########################################
  262. jnl_progress "$cmd $common_options ${cmd_args[4]}"
  263. output=$(ksh -c "$cmd $common_options ${cmd_args[4]}")
  264. e=$?
  265. if [[ $e -ne 0 ]]; then
  266. jnl_diagnostic "$cmd $common_options ${cmd_args[4]} $output" 0 $e "STF_FAIL"
  267. jnl_result $STF_FAIL
  268. cp test.xml.bak $test_db
  269. rm -f test.xml.bak
  270. rm -f result.$$
  271. exit $STF_FAIL
  272. fi
  273. jnl_progress "$cmd $list_options"
  274. $cmd $list_options > result.$$
  275. e=$?
  276. if [[ $e -ne 0 ]]; then
  277. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  278. jnl_result $STF_UNRESOLVED
  279. cp test.xml.bak $test_db
  280. rm -f test.xml.bak
  281. rm -f result.$$
  282. exit $STF_UNRESOLVED
  283. fi
  284. grep 'Response lifetime: 12-hour' result.$$
  285. e=$?
  286. if [[ $e -ne 0 ]]; then
  287. jnl_error "Can't find policy from test.xml"
  288. jnl_result $STF_FAIL
  289. cp test.xml.bak $test_db
  290. rm -f test.xml.bak
  291. rm -f result.$$
  292. exit $STF_FAIL
  293. fi
  294. # Restore test dbfile
  295. cp test.xml.bak $test_db
  296. e=$?
  297. if [[ $e -ne 0 ]]; then
  298. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  299. rm -f test.xml.bak
  300. rm -f result.$$
  301. exit $STF_UNRESOLVED
  302. fi
  303. ##########################Create cmd_args[4] END###########################################
  304. ##########################Create cmd_args[5] BEGIN#########################################
  305. jnl_progress "$cmd $common_options ${cmd_args[5]}"
  306. output=$(ksh -c "$cmd $common_options ${cmd_args[5]}")
  307. e=$?
  308. if [[ $e -ne 0 ]]; then
  309. jnl_diagnostic "$cmd $common_options ${cmd_args[5]} $output" 0 $e "STF_FAIL"
  310. jnl_result $STF_FAIL
  311. cp test.xml.bak $test_db
  312. rm -f test.xml.bak
  313. rm -f result.$$
  314. exit $STF_FAIL
  315. fi
  316. jnl_progress "$cmd $list_options"
  317. $cmd $list_options > result.$$
  318. e=$?
  319. if [[ $e -ne 0 ]]; then
  320. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  321. jnl_result $STF_UNRESOLVED
  322. cp test.xml.bak $test_db
  323. rm -f test.xml.bak
  324. rm -f result.$$
  325. exit $STF_UNRESOLVED
  326. fi
  327. grep "$issuer_dn" result.$$ && grep 'Serial: 0303' result.$$
  328. e=$?
  329. if [[ $e -ne 0 ]]; then
  330. jnl_error "Can't find policy from test.xml"
  331. jnl_result $STF_FAIL
  332. cp test.xml.bak $test_db
  333. rm -f test.xml.bak
  334. rm -f result.$$
  335. exit $STF_FAIL
  336. fi
  337. # Restore test dbfile
  338. cp test.xml.bak $test_db
  339. e=$?
  340. if [[ $e -ne 0 ]]; then
  341. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  342. rm -f test.xml.bak
  343. rm -f result.$$
  344. exit $STF_UNRESOLVED
  345. fi
  346. ##########################Create cmd_args[5] END###########################################
  347. rm -f result.$$
  348. rm -f test.xml.bak
  349. jnl_result $STF_PASS
  350. exit $STF_PASS