Skip to content

Commit dfa7816

Browse files
committed
tests/*/luks: add blackbox tests for luks
1 parent d06b0f0 commit dfa7816

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

tests/negative/luks/creation.go

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2023 CoreOS, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package luks
16+
17+
import (
18+
"github.com/coreos/ignition/v2/tests/register"
19+
"github.com/coreos/ignition/v2/tests/types"
20+
)
21+
22+
func init() {
23+
register.Register(register.NegativeTest, LuksOnNonExtDevice())
24+
}
25+
26+
func LuksOnNonExtDevice() types.Test {
27+
name := "tang.filesystem.luks.encrypt"
28+
in := types.GetBaseDisk()
29+
out := types.GetBaseDisk()
30+
mntDevices := []types.MntDevice{
31+
{
32+
Label: "EFI-SYSTEM",
33+
Substitution: "$DEVICE",
34+
},
35+
}
36+
config := `{
37+
"ignition": { "version": "$version" },
38+
"storage": {
39+
"luks": [
40+
{
41+
"device": "$DEVICE",
42+
"name": "luks-$UUID",
43+
"wipe_volume": true
44+
}
45+
]
46+
}
47+
}`
48+
configMinVersion := "3.2.0"
49+
50+
return types.Test{
51+
Name: name,
52+
In: in,
53+
Out: out,
54+
MntDevices: mntDevices,
55+
Config: config,
56+
ConfigMinVersion: configMinVersion,
57+
}
58+
}

tests/positive/luks/creation.go

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright 2023 CoreOS, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package luks
16+
17+
import (
18+
"github.com/coreos/ignition/v2/tests/register"
19+
"github.com/coreos/ignition/v2/tests/types"
20+
)
21+
22+
func init() {
23+
register.Register(register.PositiveTest, LuksWithStaticKey())
24+
25+
}
26+
27+
func LuksWithStaticKey() types.Test {
28+
name := "static.filesystem.luks.encrypt"
29+
in := types.GetBaseDisk()
30+
out := types.GetBaseDisk()
31+
mntDevices := []types.MntDevice{
32+
{
33+
Label: "OEM",
34+
Substitution: "$DEVICE",
35+
},
36+
}
37+
config := `{
38+
"ignition": { "version": "$version" },
39+
"storage": {
40+
"disks": [
41+
{
42+
"device": "$DEVICE",
43+
"partitions": [
44+
{
45+
"label": "luks-device",
46+
"sizeMiB": 0,
47+
"startMiB": 0
48+
}
49+
],
50+
"wipe_table": true
51+
}
52+
],
53+
"luks": [
54+
{
55+
"device": "$DEVICE",
56+
"name": "luks-$UUID",
57+
"keyFile": {
58+
"compression": "",
59+
"source": "data:REPLACE-THIS-WITH-YOUR-KEY-MATERIAL"
60+
},
61+
"wipe_volume": true
62+
}
63+
]
64+
}
65+
}`
66+
configMinVersion := "3.2.0"
67+
in[0].Partitions.GetPartition("OEM").FilesystemType = "ext4"
68+
out[0].Partitions.GetPartition("OEM").FilesystemType = "crypto_LUKS"
69+
70+
return types.Test{
71+
Name: name,
72+
In: in,
73+
Out: out,
74+
MntDevices: mntDevices,
75+
Config: config,
76+
ConfigMinVersion: configMinVersion,
77+
}
78+
}

tests/registry/registry.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
_ "github.com/coreos/ignition/v2/tests/positive/files"
2828
_ "github.com/coreos/ignition/v2/tests/positive/filesystems"
2929
_ "github.com/coreos/ignition/v2/tests/positive/general"
30+
_ "github.com/coreos/ignition/v2/tests/positive/luks"
3031
_ "github.com/coreos/ignition/v2/tests/positive/partitions"
3132
_ "github.com/coreos/ignition/v2/tests/positive/passwd"
3233
_ "github.com/coreos/ignition/v2/tests/positive/proxy"

0 commit comments

Comments
 (0)