// Path: src/main/java/com/google/gke/auditor/models/KubernetesRole.java
// public abstract class KubernetesRole extends Asset {
// 
//   /**
//    * A list of detected vulnerable rules.
//    */
//   private List<V1beta1PolicyRule> vulnerableRules = new ArrayList<>();
// 
//   /**
//    * Returns a list of {@link V1beta1PolicyRule}s.
//    */
//   public abstract List<V1beta1PolicyRule> getRules();
// 
//   /**
//    * Add detected vulnerable rules.
//    */
//   public void addVulnerableRules(List<V1beta1PolicyRule> vulnerableRules) {
//     this.vulnerableRules.addAll(vulnerableRules);
//   }
// 
//   @Override
//   public Builder getReport() {
//     Logger.Builder builder = Logger.builder();
//     builder.addMessage("Rules", "", Color.RED);
// 
//     Logger.Builder subMessagesBuilder = Logger.builder();
//     for (V1beta1PolicyRule rule : vulnerableRules) {
//       if (rule.getApiGroups() != null && !rule.getApiGroups().isEmpty()) {
//         subMessagesBuilder.addMessage("ApiGroups", rule.getApiGroups().toString(), Color.RED);
//       }
//       if (rule.getVerbs() != null && !rule.getVerbs().isEmpty()) {
//         subMessagesBuilder.addMessage("Verbs", rule.getVerbs().toString(), Color.RED);
//       }
//       if (rule.getResources() != null && !rule.getResources().isEmpty()) {
//         subMessagesBuilder.addMessage("Resources", rule.getResources().toString(), Color.RED);
//       }
//       if (rule.getResourceNames() != null && !rule.getResourceNames().isEmpty()) {
//         subMessagesBuilder
//             .addMessage("Resource names", rule.getResourceNames().toString(), Color.RED);
//       }
//       if (rule.getNonResourceURLs() != null && !rule.getNonResourceURLs().isEmpty()) {
//         subMessagesBuilder.addMessage("Non Resource URLs", rule.getNonResourceURLs().toString(),
//             Color.RED);
//       }
//       subMessagesBuilder.addLineBreak();
//     }
//     vulnerableRules.clear();
//     builder.addSubMessages(subMessagesBuilder);
//     return builder;
//   }
// 
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.gke.auditor.models.KubernetesRole;
import io.kubernetes.client.openapi.models.V1beta1PolicyRule;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
  @Test
  public void isVulnerableNoCreateNoPodResourceTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(List.of("get", "list"));
    when(rule.getResources()).thenReturn(List.of("nodes", "secrets"));

    KubernetesRole role = mock(KubernetesRole.class);
    when(role.getRules()).thenReturn(List.of(rule));

    assertThat(createPodsAllowed.isVulnerable(role)).isFalse();
  }

  @Test
  public void isVulnerableVerbsNullTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(null);
    when(rule.getResources()).thenReturn(List.of("pods", "nodes", "secrets"));

    KubernetesRole role = mock(KubernetesRole.class);
    when(role.getRules()).thenReturn(List.of(rule));

    assertThat(createPodsAllowed.isVulnerable(role)).isFalse();
  }

  @Test
  public void isVulnerableResourcesNullTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(List.of("get", "list"));
    when(rule.getResources()).thenReturn(null);

// Path: src/main/java/com/google/gke/auditor/models/KubernetesRole.java
// public abstract class KubernetesRole extends Asset {
// 
//   /**
//    * A list of detected vulnerable rules.
//    */
//   private List<V1beta1PolicyRule> vulnerableRules = new ArrayList<>();
// 
//   /**
//    * Returns a list of {@link V1beta1PolicyRule}s.
//    */
//   public abstract List<V1beta1PolicyRule> getRules();
// 
//   /**
//    * Add detected vulnerable rules.
//    */
//   public void addVulnerableRules(List<V1beta1PolicyRule> vulnerableRules) {
//     this.vulnerableRules.addAll(vulnerableRules);
//   }
// 
//   @Override
//   public Builder getReport() {
//     Logger.Builder builder = Logger.builder();
//     builder.addMessage("Rules", "", Color.RED);
// 
//     Logger.Builder subMessagesBuilder = Logger.builder();
//     for (V1beta1PolicyRule rule : vulnerableRules) {
//       if (rule.getApiGroups() != null && !rule.getApiGroups().isEmpty()) {
//         subMessagesBuilder.addMessage("ApiGroups", rule.getApiGroups().toString(), Color.RED);
//       }
//       if (rule.getVerbs() != null && !rule.getVerbs().isEmpty()) {
//         subMessagesBuilder.addMessage("Verbs", rule.getVerbs().toString(), Color.RED);
//       }
//       if (rule.getResources() != null && !rule.getResources().isEmpty()) {
//         subMessagesBuilder.addMessage("Resources", rule.getResources().toString(), Color.RED);
//       }
//       if (rule.getResourceNames() != null && !rule.getResourceNames().isEmpty()) {
//         subMessagesBuilder
//             .addMessage("Resource names", rule.getResourceNames().toString(), Color.RED);
//       }
//       if (rule.getNonResourceURLs() != null && !rule.getNonResourceURLs().isEmpty()) {
//         subMessagesBuilder.addMessage("Non Resource URLs", rule.getNonResourceURLs().toString(),
//             Color.RED);
//       }
//       subMessagesBuilder.addLineBreak();
//     }
//     vulnerableRules.clear();
//     builder.addSubMessages(subMessagesBuilder);
//     return builder;
//   }
// 
// }


// Path: src/test/java/com/google/gke/auditor/configs/rbac/CreatePodsAllowedTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.gke.auditor.models.KubernetesRole;
import io.kubernetes.client.openapi.models.V1beta1PolicyRule;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

  @Test
  public void isVulnerableNoCreateNoPodResourceTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(List.of("get", "list"));
    when(rule.getResources()).thenReturn(List.of("nodes", "secrets"));

    KubernetesRole role = mock(KubernetesRole.class);
    when(role.getRules()).thenReturn(List.of(rule));

    assertThat(createPodsAllowed.isVulnerable(role)).isFalse();
  }

  @Test
  public void isVulnerableVerbsNullTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(null);
    when(rule.getResources()).thenReturn(List.of("pods", "nodes", "secrets"));

    KubernetesRole role = mock(KubernetesRole.class);
    when(role.getRules()).thenReturn(List.of(rule));

    assertThat(createPodsAllowed.isVulnerable(role)).isFalse();
  }

  @Test
  public void isVulnerableResourcesNullTest() {
    V1beta1PolicyRule rule = mock(V1beta1PolicyRule.class);
    when(rule.getVerbs()).thenReturn(List.of("get", "list"));
    when(rule.getResources()).thenReturn(null);

    KubernetesRole role = mock(KubernetesRole.class);