@@ -1637,3 +1637,85 @@ func TestTranslateGrub(t *testing.T) {
1637
1637
})
1638
1638
}
1639
1639
}
1640
+
1641
+ func TestTranslateSelinux (t * testing.T ) {
1642
+ translations := []translate.Translation {
1643
+ {From : path .New ("yaml" , "version" ), To : path .New ("json" , "ignition" , "version" )},
1644
+ {From : path .New ("yaml" , "selinux" , "module" ), To : path .New ("json" , "storage" , "filesystems" )},
1645
+ {From : path .New ("yaml" , "selinux" , "module" ), To : path .New ("json" , "storage" , "filesystems" , 0 )},
1646
+ {From : path .New ("yaml" , "selinux" , "module" ), To : path .New ("json" , "storage" , "filesystems" , 0 , "path" )},
1647
+ {From : path .New ("yaml" , "selinux" , "module" ), To : path .New ("json" , "storage" , "filesystems" , 0 , "device" )},
1648
+ {From : path .New ("yaml" , "selinux" , "module" ), To : path .New ("json" , "storage" , "filesystems" , 0 , "format" )},
1649
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" )},
1650
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" )},
1651
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" , 0 )},
1652
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" , 0 , "path" )},
1653
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" , 0 , "append" )},
1654
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" , 0 , "append" , 0 )},
1655
+ {From : path .New ("yaml" , "selinux" , "module" , 0 ), To : path .New ("json" , "storage" , "files" , 0 , "append" , 0 , "source" )},
1656
+ {From : path .New ("yaml" , "selinux" , "module" , .0 ), To : path .New ("json" , "storage" , "files" , 0 , "append" , 0 , "compression" )},
1657
+ }
1658
+ tests := []struct {
1659
+ in Config
1660
+ out types.Config
1661
+ exceptions []translate.Translation
1662
+ report report.Report
1663
+ }{
1664
+ // config with one module
1665
+ {
1666
+ Config {
1667
+ Selinux : Selinux {
1668
+ Module : []Module {
1669
+ {
1670
+ Name : "some_name" ,
1671
+ Content : "some content here" ,
1672
+ },
1673
+ },
1674
+ },
1675
+ },
1676
+ types.Config {
1677
+ Ignition : types.Ignition {
1678
+ Version : "3.5.0-experimental" ,
1679
+ },
1680
+ Storage : types.Storage {
1681
+ Filesystems : []types.Filesystem {
1682
+ {
1683
+ Device : "/dev/disk/by-label/boot" ,
1684
+ Format : util .StrToPtr ("ext4" ),
1685
+ Path : util .StrToPtr ("/boot" ),
1686
+ },
1687
+ },
1688
+ Files : []types.File {
1689
+ {
1690
+ Node : types.Node {
1691
+ Path : "/etc/selinux/targeted/modules/active/extra/some_name.cil" ,
1692
+ },
1693
+ FileEmbedded1 : types.FileEmbedded1 {
1694
+ Append : []types.Resource {
1695
+ {
1696
+ Source : util .StrToPtr ("data:,some%20content%20here" ),
1697
+ Compression : util .StrToPtr ("" ),
1698
+ },
1699
+ },
1700
+ },
1701
+ },
1702
+ },
1703
+ },
1704
+ },
1705
+ translations ,
1706
+ report.Report {},
1707
+ },
1708
+ }
1709
+
1710
+ for i , test := range tests {
1711
+ t .Run (fmt .Sprintf ("translate %d" , i ), func (t * testing.T ) {
1712
+ actual , translations , r := test .in .ToIgn3_5Unvalidated (common.TranslateOptions {})
1713
+ r = confutil .TranslateReportPaths (r , translations )
1714
+ baseutil .VerifyReport (t , test .in , r )
1715
+ assert .Equal (t , test .out , actual , "translation mismatch" )
1716
+ assert .Equal (t , test .report , r , "report mismatch" )
1717
+ baseutil .VerifyTranslations (t , translations , test .exceptions )
1718
+ assert .NoError (t , translations .DebugVerifyCoverage (actual ), "incomplete TranslationSet coverage" )
1719
+ })
1720
+ }
1721
+ }
0 commit comments