Skip to content

Commit 32dbcd0

Browse files
committed
Fix CodeClimate problem
Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.
1 parent 3d98544 commit 32dbcd0

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

tests/oscap_info_profiles/test_list_rules.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ p1="xccdf_com.example.www_profile_P1"
1212

1313
# Test 1: --list-rules with --profile prints selected rule IDs
1414
$OSCAP info --profile $p1 --list-rules $ds > $stdout 2> $stderr
15-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
15+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
1616
grep -q "xccdf_com.example.www_rule_R1" $stdout
1717
grep -q "xccdf_com.example.www_rule_R2" $stdout
1818
grep -q "xccdf_com.example.www_rule_R3" $stdout
1919
grep -q "xccdf_com.example.www_rule_R4" $stdout
2020
# Verify output contains only rule IDs, one per line (4 rules = 4 lines)
21-
[ "$(wc -l < $stdout)" -eq 4 ]
21+
[[ "$(wc -l < $stdout)" -eq 4 ]]
2222
:> $stdout
2323

2424
# Test 2: --list-rules without --profile produces an error
@@ -31,24 +31,24 @@ grep -q "\-\-list-rules option requires \-\-profile" $stderr
3131
tailoring="$srcdir/test_tailoring_file.xml"
3232
tp="xccdf_com.example.www_profile_P1_tailored"
3333
$OSCAP info --profile $tp --list-rules $tailoring > $stdout 2> $stderr
34-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
34+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
3535
grep -q "xccdf_com.example.www_rule_R1" $stdout
3636
grep -q "xccdf_com.example.www_rule_R2" $stdout
3737
# R3 and R4 are deselected by tailoring
3838
! grep -q "xccdf_com.example.www_rule_R3" $stdout
3939
! grep -q "xccdf_com.example.www_rule_R4" $stdout
40-
[ "$(wc -l < $stdout)" -eq 2 ]
40+
[[ "$(wc -l < $stdout)" -eq 2 ]]
4141
:> $stdout
4242

4343
# Test 4: --list-rules with SDS containing tailoring
4444
ds_tailoring="$srcdir/test_reference_ds_with_tailoring.xml"
4545
$OSCAP info --profile $tp --list-rules $ds_tailoring > $stdout 2> $stderr
46-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
46+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
4747
grep -q "xccdf_com.example.www_rule_R1" $stdout
4848
grep -q "xccdf_com.example.www_rule_R2" $stdout
4949
! grep -q "xccdf_com.example.www_rule_R3" $stdout
5050
! grep -q "xccdf_com.example.www_rule_R4" $stdout
51-
[ "$(wc -l < $stdout)" -eq 2 ]
51+
[[ "$(wc -l < $stdout)" -eq 2 ]]
5252
:> $stdout
5353

5454
rm -f $stdout $stderr

tests/oscap_info_profiles/test_list_vars.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ p1="xccdf_com.example.www_profile_P1"
1212

1313
# Test 1: --list-vars with --profile prints value IDs and resolved values
1414
$OSCAP info --profile $p1 --list-vars $ds > $stdout 2> $stderr
15-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
15+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
1616
grep -q "xccdf_com.example.www_value_V1 42" $stdout
1717
grep -q "xccdf_com.example.www_value_V2 custom_val" $stdout
1818
# Verify output contains exactly 2 lines
19-
[ "$(wc -l < $stdout)" -eq 2 ]
19+
[[ "$(wc -l < $stdout)" -eq 2 ]]
2020
:> $stdout
2121

2222
# Test 2: --list-vars without --profile produces an error
@@ -35,20 +35,20 @@ grep -q "The \-\-list-rules and \-\-list-vars options can't be used at the same
3535
tailoring="$srcdir/test_tailoring_file.xml"
3636
tp="xccdf_com.example.www_profile_P1_tailored"
3737
$OSCAP info --profile $tp --list-vars $tailoring > $stdout 2> $stderr
38-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
38+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
3939
# V1 is overridden to 99 by tailoring, V2 is inherited from base profile
4040
grep -q "xccdf_com.example.www_value_V1 99" $stdout
4141
grep -q "xccdf_com.example.www_value_V2 custom_val" $stdout
42-
[ "$(wc -l < $stdout)" -eq 2 ]
42+
[[ "$(wc -l < $stdout)" -eq 2 ]]
4343
:> $stdout
4444

4545
# Test 5: --list-vars with SDS containing tailoring
4646
ds_tailoring="$srcdir/test_reference_ds_with_tailoring.xml"
4747
$OSCAP info --profile $tp --list-vars $ds_tailoring > $stdout 2> $stderr
48-
[ -f $stderr ]; [ ! -s $stderr ]; :> $stderr
48+
[[ -f $stderr ]]; [[ ! -s $stderr ]]; :> $stderr
4949
grep -q "xccdf_com.example.www_value_V1 99" $stdout
5050
grep -q "xccdf_com.example.www_value_V2 custom_val" $stdout
51-
[ "$(wc -l < $stdout)" -eq 2 ]
51+
[[ "$(wc -l < $stdout)" -eq 2 ]]
5252
:> $stdout
5353

5454
rm -f $stdout $stderr

0 commit comments

Comments
 (0)