You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The separate encryption specs are a byproduct of having to use a
separate command-line flag. This change moves the related code to the
cli package.
Epic: none
Release note: None
// TestParseEncryptionSpec verifies that the --enterprise-encryption arguments
1737
+
// are correctly parsed into storeEncryptionSpecs.
1738
+
funcTestParseEncryptionSpec(t*testing.T) {
1739
+
deferleaktest.AfterTest(t)()
1740
+
1741
+
absDataPath, err:=filepath.Abs("data")
1742
+
iferr!=nil {
1743
+
t.Fatal(err)
1744
+
}
1745
+
1746
+
testCases:= []struct {
1747
+
valuestring
1748
+
expectedErrstring
1749
+
expectedstoreEncryptionSpec
1750
+
}{
1751
+
// path
1752
+
{",", "no path specified", storeEncryptionSpec{}},
1753
+
{"", "no path specified", storeEncryptionSpec{}},
1754
+
{"/mnt/hda1", "field not in the form <key>=<value>: /mnt/hda1", storeEncryptionSpec{}},
1755
+
{"path=", "no value specified for path", storeEncryptionSpec{}},
1756
+
{"path=~/data", "path cannot start with '~': ~/data", storeEncryptionSpec{}},
1757
+
{"path=data,path=data2", "path field was used twice in encryption definition", storeEncryptionSpec{}},
1758
+
1759
+
// The same logic applies to key and old-key, don't repeat everything.
1760
+
{"path=data", "no key specified", storeEncryptionSpec{}},
1761
+
{"path=data,key=new.key", "no old-key specified", storeEncryptionSpec{}},
1762
+
1763
+
// Rotation period.
1764
+
{"path=data,key=new.key,old-key=old.key,rotation-period", "field not in the form <key>=<value>: rotation-period", storeEncryptionSpec{}},
1765
+
{"path=data,key=new.key,old-key=old.key,rotation-period=", "no value specified for rotation-period", storeEncryptionSpec{}},
1766
+
{"path=data,key=new.key,old-key=old.key,rotation-period=1", `could not parse rotation-duration value: 1: time: missing unit in duration "1"`, storeEncryptionSpec{}},
1767
+
{"path=data,key=new.key,old-key=old.key,rotation-period=1d", `could not parse rotation-duration value: 1d: time: unknown unit "d" in duration "1d"`, storeEncryptionSpec{}},
1768
+
1769
+
// Good values. Note that paths get absolutized so we start most of them
0 commit comments