Add QA test for secret parameter transmission
authorLisa Velden <velden@google.com>
Fri, 3 Jul 2015 11:49:48 +0000 (13:49 +0200)
committerLisa Velden <velden@google.com>
Wed, 8 Jul 2015 10:28:43 +0000 (12:28 +0200)
This test is done with the newly introduced opcode 'gnt-debug
test-osparams'. Redaction of secret parameters within the job file is
also tested again with this opcode.

Signed-off-by: Lisa Velden <velden@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

qa/ganeti-qa.py
qa/qa_instance.py

index 885aa66..ea61b53 100755 (executable)
@@ -1065,6 +1065,7 @@ def RunQa():
     qa_instance.TestInstanceCreationRestrictedByDiskTemplates)
 
   RunTestIf("instance-add-osparams", qa_instance.TestInstanceAddOsParams)
+  RunTestIf("instance-add-osparams", qa_instance.TestSecretOsParams)
 
   # Test removing instance with offline drbd secondary
   if qa_config.TestEnabled(["instance-remove-drbd-offline",
index eda27ab..f0928c5 100644 (file)
@@ -1565,6 +1565,21 @@ def TestInstanceAddOsParams():
   pnode.Release()
 
 
+def TestSecretOsParams():
+  """Tests secret os parameter transmission"""
+
+  secret_keys = ["param1", "param2"]
+  cmd = (["gnt-debug", "test-osparams", "--os-parameters-secret",
+         "param1=secret1,param2=secret2", "--submit", "--print-jobid"])
+  _TestRedactionOfSecretOsParams(cmd, secret_keys)
+
+  cmd_output = stdout_of(["gnt-debug", "test-osparams",
+                         "--os-parameters-secret",
+                         "param1=secret1,param2=secret2"])
+  AssertIn("\'param1\': \'secret1\'", cmd_output)
+  AssertIn("\'param2\': \'secret2\'", cmd_output)
+
+
 available_instance_tests = [
   ("instance-add-plain-disk", constants.DT_PLAIN,
    TestInstanceAddWithPlainDisk, 1),