Skip to content

Commit e6135fb

Browse files
authored
b/433135671 Use non-static classes for nested test fixtures (#736)
Ensure that all tests are executed, both in IntelliJ and in mvn.
1 parent 6bb5d3e commit e6135fb

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

sources/src/test/java/com/google/solutions/jitaccess/catalog/legacy/TestLegacyPolicy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public void add_whenProjectHasMultipleBindingsForSameRoleWithDifferentConditions
302302
}
303303

304304
@Nested
305-
public static class ProjectPolicy {
305+
public class ProjectPolicy {
306306

307307
//---------------------------------------------------------------------------
308308
// createName.
@@ -316,7 +316,7 @@ public void createName() {
316316
}
317317

318318
@Nested
319-
public static class RolePolicy {
319+
public class RolePolicy {
320320

321321
//---------------------------------------------------------------------------
322322
// createName.

sources/src/test/java/com/google/solutions/jitaccess/catalog/policy/TestPolicyDocument.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void fromString() throws Exception {
200200
//---------------------------------------------------------------------------
201201

202202
@Nested
203-
public static class Issue {
203+
public class Issue {
204204
@Test
205205
public void toString_whenError() {
206206
var issue = new PolicyDocument.Issue(true, null, PolicyDocument.Issue.Code.FILE_INVALID, "Error!!1");
@@ -219,7 +219,7 @@ public void toString_whenWarning() {
219219
//---------------------------------------------------------------------------
220220

221221
@Nested
222-
public static class EnvironmentElement {
222+
public class EnvironmentElement {
223223

224224
@Test
225225
public void toYaml_whenAclIsEmpty() {
@@ -396,7 +396,7 @@ public void toPolicy() {
396396
//---------------------------------------------------------------------------
397397

398398
@Nested
399-
public static class SystemElement {
399+
public class SystemElement {
400400
@Test
401401
public void toYaml_whenAclIsNull() {
402402
var policy = new SystemPolicy("sys", "System", null, Map.of());
@@ -545,7 +545,7 @@ public void toPolicy() {
545545
//---------------------------------------------------------------------------
546546

547547
@Nested
548-
public static class GroupElement {
548+
public class GroupElement {
549549
@Test
550550
public void toYaml_whenAclIsEmpty() {
551551
var policy = new JitGroupPolicy(
@@ -627,7 +627,7 @@ public void toYaml_whenGkeEnabled() {
627627
AccessControlList.EMPTY,
628628
Map.of(),
629629
List.of(),
630-
false);
630+
true);
631631
var element = PolicyDocument.GroupElement.toYaml(policy);
632632

633633
assertEquals("group", element.name());
@@ -675,7 +675,6 @@ public void toPolicy_whenAclInvalid() {
675675
assertEquals(
676676
PolicyDocument.Issue.Code.ACL_INVALID_PRINCIPAL,
677677
issues.issues().get(0).code());
678-
assertFalse(policy.get().isGkeEnabled());
679678
}
680679

681680
@Test
@@ -697,7 +696,6 @@ public void toPolicy_whenConstraintInvalid() {
697696
assertEquals(
698697
PolicyDocument.Issue.Code.CONSTRAINT_INVALID_TYPE,
699698
issues.issues().get(0).code());
700-
assertFalse(policy.get().isGkeEnabled());
701699
}
702700

703701
@Test
@@ -721,7 +719,6 @@ public void toPolicy_whenJoinConstraintsContainMultipleExpiryConstraints() {
721719
assertEquals(
722720
PolicyDocument.Issue.Code.CONSTRAINT_INVALID_EXPIRY,
723721
issues.issues().get(0).code());
724-
assertFalse(policy.get().isGkeEnabled());
725722
}
726723

727724
@Test
@@ -742,7 +739,6 @@ public void toPolicy_whenApprovalConstraintsContainExpiryConstraint() {
742739
assertEquals(
743740
PolicyDocument.Issue.Code.CONSTRAINT_INVALID_EXPIRY,
744741
issues.issues().get(0).code());
745-
assertFalse(policy.get().isGkeEnabled());
746742
}
747743

748744
@Test
@@ -763,7 +759,6 @@ public void toPolicy_whenBindingInvalid() {
763759
assertEquals(
764760
PolicyDocument.Issue.Code.PRIVILEGE_INVALID_RESOURCE_ID,
765761
issues.issues().get(0).code());
766-
assertFalse(policy.get().isGkeEnabled());
767762
}
768763

769764
@Test
@@ -793,7 +788,7 @@ public void toPolicy() {
793788
//---------------------------------------------------------------------------
794789

795790
@Nested
796-
public static class AccessControlEntryElement {
791+
public class AccessControlEntryElement {
797792
@Test
798793
public void toYaml_whenAllowMaskCombinesMultipleValues() {
799794
var ace = new AccessControlList.AllowedEntry(SAMPLE_USER, 15);
@@ -898,7 +893,7 @@ public void toPolicy(String principalId) {
898893
//---------------------------------------------------------------------------
899894

900895
@Nested
901-
public static class ConstraintElement {
896+
public class ConstraintElement {
902897
@Test
903898
public void toYaml_whenFixedExpiry() {
904899
var constraint = new ExpiryConstraint(Duration.ofMinutes(5));
@@ -1106,7 +1101,7 @@ public void toPolicy_whenExpressionHasNoVariables() {
11061101
//---------------------------------------------------------------------------
11071102

11081103
@Nested
1109-
public static class CelVariableElement {
1104+
public class CelVariableElement {
11101105
@Test
11111106
public void toYaml_whenTypeInvalid() {
11121107
var variable = new CelConstraint.Variable("test", "test") {
@@ -1239,7 +1234,7 @@ public void toPolicy_whenBoolean(String type) {
12391234
//---------------------------------------------------------------------------
12401235

12411236
@Nested
1242-
public static class IamRoleBindingElement {
1237+
public class IamRoleBindingElement {
12431238
@Test
12441239
public void toYaml_whenTypeInvalid() {
12451240
var binding = new IamRoleBinding(

sources/src/test/java/com/google/solutions/jitaccess/web/proposal/TestMailProposalHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void onProposalApproved() throws Exception {
133133
}
134134

135135
@Nested
136-
public static class MailTemplate {
136+
public class MailTemplate {
137137

138138
//-------------------------------------------------------------------------
139139
// fromResource.

sources/src/test/java/com/google/solutions/jitaccess/web/rest/TestEnvironmentsResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public void reconcile_whenPermissionsInsufficient() {
401401
}
402402

403403
@Nested
404-
public static class EnvironmentInfo {
404+
public class EnvironmentInfo {
405405
@Test
406406
public void create_whenExportAndReconcileNotAllowed() {
407407
var environment = new EnvironmentPolicy(

0 commit comments

Comments
 (0)