@@ -131,50 +131,52 @@ func TestRuleTypes(t *testing.T) {
131
131
132
132
require .NoError (t , os .Setenv ("REGO_ENABLE_PRINT" , "true" ))
133
133
134
- // iterate rule types directory
135
- err := walkRuleTypesTests (t , func (t * testing.T , rt * minderv1.RuleType , tc * RuleTest , rtDataPath string ) {
136
- var opts []tkv1.Option
137
- if rt .Def .Ingest .Type == "git" {
138
- opts = append (opts , gitTestOpts (t , tc , rtDataPath ))
139
- } else if rt .Def .Ingest .Type == "rest" {
140
- opts = append (opts , httpTestOpts (t , tc , rtDataPath ))
141
- } else {
142
- t .Skipf ("Unsupported ingest type %s" , rt .Def .Ingest .Type )
143
- }
134
+ for _ , folder := range []string {"rule-types" , "security-baseline/rule-types" } {
135
+ // iterate rule types directory
136
+ err := walkRuleTypesTests (t , folder , func (t * testing.T , rt * minderv1.RuleType , tc * RuleTest , rtDataPath string ) {
137
+ var opts []tkv1.Option
138
+ if rt .Def .Ingest .Type == "git" {
139
+ opts = append (opts , gitTestOpts (t , tc , rtDataPath ))
140
+ } else if rt .Def .Ingest .Type == "rest" {
141
+ opts = append (opts , httpTestOpts (t , tc , rtDataPath ))
142
+ } else {
143
+ t .Skipf ("Unsupported ingest type %s" , rt .Def .Ingest .Type )
144
+ }
144
145
145
- ztw := zerolog .NewTestWriter (t )
146
- zerolog .SetGlobalLevel (zerolog .DebugLevel )
147
- ctx := zerolog .New (ztw ).With ().Timestamp ().Logger ().WithContext (context .Background ())
146
+ ztw := zerolog .NewTestWriter (t )
147
+ zerolog .SetGlobalLevel (zerolog .DebugLevel )
148
+ ctx := zerolog .New (ztw ).With ().Timestamp ().Logger ().WithContext (context .Background ())
148
149
149
- tk := tkv1 .NewTestKit (opts ... )
150
- rte , err := rtengine .NewRuleTypeEngine (ctx , rt , tk , nil )
151
- require .NoError (t , err )
150
+ tk := tkv1 .NewTestKit (opts ... )
151
+ rte , err := rtengine .NewRuleTypeEngine (ctx , rt , tk , nil )
152
+ require .NoError (t , err )
152
153
153
- val := rte .GetRuleInstanceValidator ()
154
- require .NoError (t , val .ValidateRuleDefAgainstSchema (tc .Def ), "Failed to validate rule definition against schema" )
155
- require .NoError (t , val .ValidateParamsAgainstSchema (tc .Params ), "Failed to validate params against schema" )
154
+ val := rte .GetRuleInstanceValidator ()
155
+ require .NoError (t , val .ValidateRuleDefAgainstSchema (tc .Def ), "Failed to validate rule definition against schema" )
156
+ require .NoError (t , val .ValidateParamsAgainstSchema (tc .Params ), "Failed to validate params against schema" )
156
157
157
- if tk .ShouldOverrideIngest () {
158
- rte .WithCustomIngester (tk )
159
- }
158
+ if tk .ShouldOverrideIngest () {
159
+ rte .WithCustomIngester (tk )
160
+ }
160
161
161
- _ , err = rte .Eval (ctx , tc .Entity .Entity , tc .Def , tc .Params , tkv1 .NewVoidResultSink ())
162
- if tc .Expect == ExpectPass {
163
- require .NoError (t , err )
164
- } else {
165
- require .Error (t , err )
166
- }
167
- })
162
+ _ , err = rte .Eval (ctx , tc .Entity .Entity , tc .Def , tc .Params , tkv1 .NewVoidResultSink ())
163
+ if tc .Expect == ExpectPass {
164
+ require .NoError (t , err )
165
+ } else {
166
+ require .Error (t , err )
167
+ }
168
+ })
168
169
169
- if err != nil {
170
- t .Error (err )
170
+ if err != nil {
171
+ t .Error (err )
172
+ }
171
173
}
172
174
}
173
175
174
- func walkRuleTypesTests (t * testing.T , testfunc RuleTypeTestFunc ) error {
176
+ func walkRuleTypesTests (t * testing.T , folder string , testfunc RuleTypeTestFunc ) error {
175
177
t .Helper ()
176
178
177
- return filepath .Walk ("rule-types" , func (path string , info os.FileInfo , err error ) error {
179
+ return filepath .Walk (folder , func (path string , info os.FileInfo , err error ) error {
178
180
if err != nil {
179
181
return err
180
182
}
0 commit comments