PageRenderTime 54ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/illumos/illumos-stc
Korn Shell | 300 lines | 214 code | 25 blank | 61 comment | 11 complexity | f9ed0ef1647a6953434a893da50118f8 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_003
  33. #
  34. # DESCRIPTION:
  35. #
  36. # Verify:
  37. # "kmfcfg create" with appropriate options can create policies with
  38. # CRL 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 crl
  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 crl 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. CRL 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. set -A cmd_args \
  70. "crl-get-crl-uri=true crl-proxy=webcache.sfbay:8080" \
  71. "crl-basefilename=testcrl.pem crl-directory=/var/tmp" \
  72. "crl-basefilename=testcrl.pem crl-ignore-crl-sign=true" \
  73. "crl-basefilename=testcrl.pem crl-ignore-crl-date=true" \
  74. # Back up test.xml
  75. jnl_progress "Backup the original dbfile test.xml"
  76. cp $test_db test.xml.bak
  77. e=$?
  78. if [[ $e -ne 0 ]]; then
  79. jnl_diagnostic "Backup test dbfile" "0" $e "STF_UNRESOLVED"
  80. rm -f test.xml.bak
  81. exit $STF_UNRESOLVED
  82. fi
  83. output=""
  84. ##########################Create cmd_args[0] BEGIN#########################################
  85. jnl_progress "$cmd $common_options ${cmd_args[0]}"
  86. output=$($cmd $common_options ${cmd_args[0]})
  87. e=$?
  88. if [[ $e -ne 0 ]]; then
  89. jnl_diagnostic "$cmd $common_options ${cmd_args[0]} $output" 0 $e "STF_FAIL"
  90. jnl_result $STF_FAIL
  91. cp test.xml.bak $test_db
  92. rm -f test.xml.bak
  93. exit $STF_FAIL
  94. fi
  95. jnl_progress "$cmd $list_options"
  96. $cmd $list_options > result.$$
  97. e=$?
  98. if [[ $e -ne 0 ]]; then
  99. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  100. jnl_result $STF_UNRESOLVED
  101. cp test.xml.bak $test_db
  102. rm -f test.xml.bak
  103. rm -f result.$$
  104. exit $STF_UNRESOLVED
  105. fi
  106. grep 'Download and cache CRL: true' result.$$ && \
  107. grep 'Proxy: webcache.sfbay:8080' result.$$
  108. e=$?
  109. if [[ $e -ne 0 ]]; then
  110. jnl_error "Can't find policy from test.xml"
  111. jnl_result $STF_FAIL
  112. cp test.xml.bak $test_db
  113. rm -f test.xml.bak
  114. rm -f result.$$
  115. exit $STF_FAIL
  116. fi
  117. # Restore test dbfile
  118. cp test.xml.bak $test_db
  119. e=$?
  120. if [[ $e -ne 0 ]]; then
  121. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  122. rm -f test.xml.bak
  123. rm -f result.$$
  124. exit $STF_UNRESOLVED
  125. fi
  126. ##########################Create cmd_args[0] END###########################################
  127. ##########################Create cmd_args[1] BEGIN#########################################
  128. jnl_progress "$cmd $common_options ${cmd_args[1]}"
  129. output=$($cmd $common_options ${cmd_args[1]})
  130. e=$?
  131. if [[ $e -ne 0 ]]; then
  132. jnl_diagnostic "$cmd $common_options ${cmd_args[1]} $output" 0 $e "STF_FAIL"
  133. jnl_result $STF_FAIL
  134. cp test.xml.bak $test_db
  135. rm -f test.xml.bak
  136. exit $STF_FAIL
  137. fi
  138. jnl_progress "$cmd $list_options"
  139. $cmd $list_options > result.$$
  140. e=$?
  141. if [[ $e -ne 0 ]]; then
  142. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  143. jnl_result $STF_UNRESOLVED
  144. cp test.xml.bak $test_db
  145. rm -f test.xml.bak
  146. rm -f result.$$
  147. exit $STF_UNRESOLVED
  148. fi
  149. grep 'Base filename: testcrl.pem' result.$$ && \
  150. grep 'Directory: /var/tmp' result.$$
  151. e=$?
  152. if [[ $e -ne 0 ]]; then
  153. jnl_error "Can't find policy from test.xml"
  154. jnl_result $STF_FAIL
  155. cp test.xml.bak $test_db
  156. rm -f test.xml.bak
  157. rm -f result.$$
  158. exit $STF_FAIL
  159. fi
  160. # Restore test dbfile
  161. cp test.xml.bak $test_db
  162. e=$?
  163. if [[ $e -ne 0 ]]; then
  164. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  165. rm -f test.xml.bak
  166. rm -f result.$$
  167. exit $STF_UNRESOLVED
  168. fi
  169. ##########################Create cmd_args[1] END###########################################
  170. ##########################Create cmd_args[2] BEGIN#########################################
  171. jnl_progress "$cmd $common_options ${cmd_args[2]}"
  172. output=$($cmd $common_options ${cmd_args[2]})
  173. e=$?
  174. if [[ $e -ne 0 ]]; then
  175. jnl_diagnostic "$cmd $common_options ${cmd_args[2]} $output" 0 $e "STF_FAIL"
  176. jnl_result $STF_FAIL
  177. cp test.xml.bak $test_db
  178. rm -f test.xml.bak
  179. rm -f result.$$
  180. exit $STF_FAIL
  181. fi
  182. jnl_progress "$cmd $list_options"
  183. $cmd $list_options > result.$$
  184. e=$?
  185. if [[ $e -ne 0 ]]; then
  186. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  187. jnl_result $STF_UNRESOLVED
  188. cp test.xml.bak $test_db
  189. rm -f test.xml.bak
  190. rm -f result.$$
  191. exit $STF_UNRESOLVED
  192. fi
  193. grep 'Base filename: testcrl.pem' result.$$ && \
  194. grep 'Ignore CRL signature: true' result.$$
  195. e=$?
  196. if [[ $e -ne 0 ]]; then
  197. jnl_error "Can't find policy from test.xml"
  198. jnl_result $STF_FAIL
  199. cp test.xml.bak $test_db
  200. rm -f test.xml.bak
  201. rm -f result.$$
  202. exit $STF_FAIL
  203. fi
  204. # Restore test dbfile
  205. cp test.xml.bak $test_db
  206. e=$?
  207. if [[ $e -ne 0 ]]; then
  208. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  209. rm -f test.xml.bak
  210. rm -f result.$$
  211. exit $STF_UNRESOLVED
  212. fi
  213. ##########################Create cmd_args[2] END###########################################
  214. ##########################Create cmd_args[3] BEGIN#########################################
  215. jnl_progress "$cmd $common_options ${cmd_args[3]}"
  216. output=$($cmd $common_options ${cmd_args[3]})
  217. e=$?
  218. if [[ $e -ne 0 ]]; then
  219. jnl_diagnostic "$cmd $common_options ${cmd_args[3]} $output" 0 $e "STF_FAIL"
  220. jnl_result $STF_FAIL
  221. cp test.xml.bak $test_db
  222. rm -f test.xml.bak
  223. rm -f result.$$
  224. exit $STF_FAIL
  225. fi
  226. jnl_progress "$cmd $list_options"
  227. $cmd $list_options > result.$$
  228. e=$?
  229. if [[ $e -ne 0 ]]; then
  230. jnl_diagnostic "$cmd $list_options" 0 $e "STF_UNRESOLVED"
  231. jnl_result $STF_UNRESOLVED
  232. cp test.xml.bak $test_db
  233. rm -f test.xml.bak
  234. rm -f result.$$
  235. exit $STF_UNRESOLVED
  236. fi
  237. grep 'Base filename: testcrl.pem' result.$$ && \
  238. grep 'Ignore CRL validity date: true' result.$$
  239. e=$?
  240. if [[ $e -ne 0 ]]; then
  241. jnl_error "Can't find policy from test.xml"
  242. jnl_result $STF_FAIL
  243. cp test.xml.bak $test_db
  244. rm -f test.xml.bak
  245. rm -f result.$$
  246. exit $STF_FAIL
  247. fi
  248. # Restore test dbfile
  249. cp test.xml.bak $test_db
  250. e=$?
  251. if [[ $e -ne 0 ]]; then
  252. jnl_diagnostic "Restore test dbfile" "0" $e "STF_UNRESOLVED"
  253. rm -f test.xml.bak
  254. rm -f result.$$
  255. exit $STF_UNRESOLVED
  256. fi
  257. ##########################Create cmd_args[3] END###########################################
  258. rm -f result.$$
  259. rm -f test.xml.bak
  260. jnl_result $STF_PASS
  261. exit $STF_PASS