test - AWS CloudFormation Guard

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

test

根據 JSON 或 YAML 格式的 Guard 單位測試檔案驗證 AWS CloudFormation Guard 規則檔案,以判斷個別規則是否成功。

語法

cfn-guard test --rules-file <value> --test-data <value>

參數

-a, --alphabetical

在目錄中依字母順序排序。

-h, --help

列印說明資訊。

-m, --last-modified

依目錄中上次修改的時間排序

-V, --version

列印版本資訊。

-v, --verbose

增加輸出詳細程度。可以多次指定。

詳細輸出遵循 Guard 規則檔案的結構。規則檔案中的每個區塊都是詳細輸出中的區塊。最上方的區塊是每個規則。如果有針對規則when的條件,它們會顯示為同盟條件區塊。

選項

-d, --dir

提供規則的根目錄。

-o, --output-format

指定輸出應顯示的格式。

預設single-line-summary

允許的值json | yaml | single-line-summary | junit

-r, --rules-file

提供規則檔案的名稱。

-t, --test-data

為 JSON 或 YAML 格式的資料檔案提供檔案或目錄的名稱。

範例

cfn-guard test --rules-file rules.guard --test-data example.json

輸出

PASS|FAIL Expected Rule = rule_name, Status = SKIP|FAIL|PASS, Got Status = SKIP|FAIL|PASS

另請參閱

測試 Guard 規則