io.fabric8.kubernetes.api.model.SecretBuilder Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.SecretBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaAssemblyOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("data")
public void testCreateClusterWithJmxEnabled(Params params, VertxTestContext context) {
    setFields(params);
    Kafka kafka = getKafkaAssembly("foo");
    kafka.getSpec().getKafka().setJmxOptions(new KafkaJmxOptionsBuilder()
        .withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build())
        .build());
    createCluster(context, kafka,
            Collections.singletonList(new SecretBuilder()
                    .withNewMetadata()
                        .withName(KafkaCluster.jmxSecretName("foo"))
                        .withNamespace("test")
                    .endMetadata()
                    .withData(Collections.singletonMap("foo", "bar"))
                    .build()
            )); //getInitialCertificates(getKafkaAssembly("foo").getMetadata().getName()));
}
 
Example #2
Source File: DockerRegistrySecretEnricherTest.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
private Secret createBaseSecret(boolean withAnnotation) {
    ObjectMetaBuilder metaBuilder = new ObjectMetaBuilder()
            .withNamespace("default");

    if (withAnnotation) {
        Map<String, String> annotations = new HashMap<>();
        annotations.put(annotation, dockerUrl);
        metaBuilder = metaBuilder.withAnnotations(annotations);
    }

    Map<String, String> data = new HashMap<>();
    return new SecretBuilder()
        .withData(data)
        .withMetadata(metaBuilder.build())
        .withType(SecretConstants.DOCKER_CONFIG_TYPE)
        .build();
}
 
Example #3
Source File: IngressTlsProvisioner.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
private void provisionTlsSecret(KubernetesEnvironment k8sEnv, String wsTlsSecretName) {
  Map<String, String> data = new HashMap<>();
  data.put("tls.crt", tlsCert);
  data.put("tls.key", tlsKey);

  Secret tlsSecret =
      new SecretBuilder()
          .withNewMetadata()
          .withName(wsTlsSecretName)
          .endMetadata()
          .withStringData(data)
          .withType(TLS_SECRET_TYPE)
          .build();

  k8sEnv.getSecrets().put(wsTlsSecretName, tlsSecret);
}
 
Example #4
Source File: SecretsController.java    From rabbitmq-operator with Apache License 2.0 6 votes vote down vote up
@Override
public Secret createOrUpdate(final Secret resource) {
    final Secret maybeExistingResource = get(resource.getMetadata().getName(), resource.getMetadata().getNamespace());

    if (maybeExistingResource == null) {
        log.info("Creating resource of type {} with name {}", getResourceType(), resource.getMetadata().getName());
        return operation().inNamespace(resource.getMetadata().getNamespace()).withName(resource.getMetadata().getName()).create(resource);
    } else {
        log.info("Patching metadata for resource type Secret with name {} - leaving Secret payload alone", resource.getMetadata().getName());
        final Secret patchedSecret = new SecretBuilder(resource)
                .withStringData(maybeExistingResource.getStringData())
                .withData(maybeExistingResource.getData())
                .build();

        return patch(patchedSecret);
    }
}
 
Example #5
Source File: EnvironmentVariableSecretApplierTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Test(
    expectedExceptions = InfrastructureException.class,
    expectedExceptionsMessageRegExp =
        "Unable to mount secret 'test_secret': It is configured to be mount as a environment variable, but its name was not specified. Please define the 'che.eclipse.org/env-name' annotation on the secret to specify it.")
public void shouldThrowExceptionWhenNoEnvNameSpecifiedSingleValue() throws Exception {
  Container container_match = new ContainerBuilder().withName("maven").build();

  when(podSpec.getContainers()).thenReturn(ImmutableList.of(container_match));

  Secret secret =
      new SecretBuilder()
          .withData(singletonMap("foo", "random"))
          .withMetadata(
              new ObjectMetaBuilder()
                  .withName("test_secret")
                  .withAnnotations(
                      ImmutableMap.of(ANNOTATION_MOUNT_AS, "env", ANNOTATION_AUTOMOUNT, "true"))
                  .withLabels(emptyMap())
                  .build())
          .build();

  when(secrets.get(any(LabelSelector.class))).thenReturn(singletonList(secret));
  secretApplier.applySecret(environment, runtimeIdentity, secret);
}
 
Example #6
Source File: EnvironmentVariableSecretApplierTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Test(
    expectedExceptions = InfrastructureException.class,
    expectedExceptionsMessageRegExp =
        "Unable to mount key 'foo'  of secret 'test_secret': It is configured to be mount as a environment variable, but its name was not specified. Please define the 'che.eclipse.org/foo_env-name' annotation on the secret to specify it.")
public void shouldThrowExceptionWhenNoEnvNameSpecifiedMultiValue() throws Exception {
  Container container_match = new ContainerBuilder().withName("maven").build();

  when(podSpec.getContainers()).thenReturn(ImmutableList.of(container_match));

  Secret secret =
      new SecretBuilder()
          .withData(ImmutableMap.of("foo", "random", "bar", "test"))
          .withMetadata(
              new ObjectMetaBuilder()
                  .withName("test_secret")
                  .withAnnotations(
                      ImmutableMap.of(ANNOTATION_MOUNT_AS, "env", ANNOTATION_AUTOMOUNT, "true"))
                  .withLabels(emptyMap())
                  .build())
          .build();

  when(secrets.get(any(LabelSelector.class))).thenReturn(singletonList(secret));
  secretApplier.applySecret(environment, runtimeIdentity, secret);
}
 
Example #7
Source File: FileDataSecretEnricher.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
private void addAnnotations(KubernetesListBuilder builder) {
    builder.accept(new TypedVisitor<SecretBuilder>() {

        @Override
        public void visit(SecretBuilder element) {
            final Map<String, String> annotations = element.buildMetadata().getAnnotations();
            try {
                if (annotations != null && !annotations.isEmpty()) {
                    final Map<String, String> secretAnnotations = createSecretFromAnnotations(annotations);
                    element.addToData(secretAnnotations);
                }
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });
}
 
Example #8
Source File: KnativeSecretHandler.java    From module-ballerina-kubernetes with Apache License 2.0 6 votes vote down vote up
private void generate(SecretModel secretModel) throws KubernetesPluginException {
    Secret secret = new SecretBuilder()
            .withNewMetadata()
            .withNamespace(knativeDataHolder.getNamespace())
            .withName(secretModel.getName())
            .endMetadata()
            .withData(secretModel.getData())
            .build();
    try {
        String secretContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(secret);
        KnativeUtils.writeToFile(secretContent, SECRET_FILE_POSTFIX + YAML);
    } catch (IOException e) {
        String errorMessage = "error while generating yaml file for secret: " + secretModel.getName();
        throw new KubernetesPluginException(errorMessage, e);
    }
}
 
Example #9
Source File: SecretHandler.java    From module-ballerina-kubernetes with Apache License 2.0 6 votes vote down vote up
private void generate(SecretModel secretModel) throws KubernetesPluginException {
    Secret secret = new SecretBuilder()
            .withNewMetadata()
            .withNamespace(dataHolder.getNamespace())
            .withName(secretModel.getName())
            .endMetadata()
            .withData(secretModel.getData())
            .build();
    try {
        String secretContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(secret);
        KubernetesUtils.writeToFile(secretContent, SECRET_FILE_POSTFIX +
                YAML);
    } catch (IOException e) {
        String errorMessage = "error while generating yaml file for secret: " + secretModel.getName();
        throw new KubernetesPluginException(errorMessage, e);
    }
}
 
Example #10
Source File: AddBasicAuthSecretDecorator.java    From dekorate with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(KubernetesListBuilder list) {
  ObjectMeta meta = getMandatoryDeploymentMetadata(list);
  String name = Strings.isNullOrEmpty(this.name) ? meta.getName() : this.name;

  Map<String, String> data = new HashMap<String, String>() {
    {
      put(USERNAME, username);
      put(PASSWORD, password);
    }
  };

  list.addToItems(new SecretBuilder()
                  .withNewMetadata()
                    .withName(name)
                  .withAnnotations(annotations)
                  .endMetadata()
      .withType(KUBERNETES_IO_BASIC_AUTH).addToStringData(data).build());
}
 
Example #11
Source File: SystemtestsKubernetesApps.java    From enmasse with Apache License 2.0 6 votes vote down vote up
private static Secret getBrokerSecret(String name, BrokerCertBundle certBundle, String user, String password) throws Exception {
    Map<String, String> data = new HashMap<>();

    byte[] content = Files.readAllBytes(new File("src/main/resources/broker/broker.xml").toPath());
    data.put("broker.xml", Base64.getEncoder().encodeToString(content));

    data.put("broker.ks", Base64.getEncoder().encodeToString(certBundle.getKeystore()));
    data.put("broker.ts", Base64.getEncoder().encodeToString(certBundle.getTruststore()));
    data.put("ca.crt", Base64.getEncoder().encodeToString(certBundle.getCaCert()));

    return new SecretBuilder()
            .withNewMetadata()
            .withName(name)
            .endMetadata()
            .addToData(data)
            .addToStringData("user", user)
            .addToStringData("password", password)
            .build();
}
 
Example #12
Source File: SecretsPropertySourceTest.java    From spring-cloud-kubernetes with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
	KubernetesClient mockClient = server.getClient();

	// Configure the kubernetes master url to point to the mock server
	System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY,
			mockClient.getConfiguration().getMasterUrl());
	System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true");
	System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false");
	System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY,
			"false");
	System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, NAMESPACE);
	System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");

	Secret secret = new SecretBuilder().withNewMetadata()
			.withLabels(singletonMap("foo", "bar")).endMetadata()
			.addToData("secretName",
					Base64.getEncoder().encodeToString(SECRET_VALUE.getBytes()))
			.build();
	mockClient.secrets().inNamespace(NAMESPACE).create(secret);
}
 
Example #13
Source File: PropagationPolicyTest.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("Should delete a Service with PropagationPolicy=Background")
void testDeleteSecret() throws InterruptedException {
  // Given
  server.expect().delete().withPath("/api/v1/namespaces/ns1/secrets/mysecret")
    .andReturn(HttpURLConnection.HTTP_OK, new SecretBuilder().build())
    .once();
  KubernetesClient client = server.getClient();

  // When
  Boolean isDeleted = client.secrets().inNamespace("ns1").withName("mysecret").delete();

  // Then
  assertTrue(isDeleted);
  assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest());
}
 
Example #14
Source File: SecretCertProvider.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
/**
 * Create a Kubernetes secret containing the provided secret data section
 *
 * @param namespace Namespace
 * @param name Secret name
 * @param data Map with secret data / files
 * @param labels Labels to add to the Secret
 * @param annotations annotations to add to the Secret
 * @param ownerReference owner of the Secret
 * @return the Secret
 */
public Secret createSecret(String namespace, String name, Map<String, String> data,
                           Map<String, String> labels, Map<String, String> annotations, OwnerReference ownerReference) {
    List<OwnerReference> or = ownerReference != null ? singletonList(ownerReference) : emptyList();
    Secret secret = new SecretBuilder()
            .withNewMetadata()
                .withName(name)
                .withNamespace(namespace)
                .withLabels(labels)
                .withAnnotations(annotations)
                .withOwnerReferences(or)
            .endMetadata()
            .withData(data)
            .build();

    return secret;
}
 
Example #15
Source File: KubernetesGCPServiceAccountSecretManagerTest.java    From styx with Apache License 2.0 6 votes vote down vote up
private static Secret fakeServiceAccountKeySecret(String serviceAccount, long epoch, String jsonKeyId,
    String p12KeyId, String creationTimestamp) {
  final String jsonKeyName = keyName(serviceAccount, jsonKeyId);
  final String p12KeyName = keyName(serviceAccount, p12KeyId);

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setCreationTimestamp(creationTimestamp);
  metadata.setName("styx-wf-sa-keys-" + epoch + "-" + Hashing.sha256().hashString(serviceAccount, UTF_8));
  metadata.setAnnotations(Map.of(
      "styx-wf-sa", serviceAccount,
      "styx-wf-sa-json-key-name", jsonKeyName,
      "styx-wf-sa-p12-key-name", p12KeyName));

  return new SecretBuilder()
      .withMetadata(metadata)
      .withData(Map.of(
          "styx-wf-sa.json", "json-private-key-data",
          "styx-wf-sa.p12", "p12-private-key-data"))
      .build();
}
 
Example #16
Source File: ModelUtils.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public static Secret createSecret(String name, String namespace, Labels labels, OwnerReference ownerReference, Map<String, String> data) {
    if (ownerReference == null) {
        return new SecretBuilder()
                .withNewMetadata()
                .withName(name)
                .withNamespace(namespace)
                .withLabels(labels.toMap())
                .endMetadata()
                .withData(data).build();
    } else {
        return new SecretBuilder()
                .withNewMetadata()
                .withName(name)
                .withOwnerReferences(ownerReference)
                .withNamespace(namespace)
                .withLabels(labels.toMap())
                .endMetadata()
                .withData(data).build();
    }
}
 
Example #17
Source File: ResourceUtils.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public static Secret createUserSecretTls()  {
    return new SecretBuilder()
            .withNewMetadata()
                .withName(NAME)
                .withNamespace(NAMESPACE)
                .withLabels(Labels.fromMap(LABELS)
                    .withKubernetesName(KafkaUserModel.KAFKA_USER_OPERATOR_NAME)
                    .withKubernetesInstance(NAME)
                    .withKubernetesPartOf(NAME)
                    .withKubernetesManagedBy(KafkaUserModel.KAFKA_USER_OPERATOR_NAME)
                    .withStrimziKind(KafkaUser.RESOURCE_KIND)
                    .toMap())
            .endMetadata()
            .addToData("ca.crt", Base64.getEncoder().encodeToString("clients-ca-crt".getBytes()))
            .addToData("user.key", Base64.getEncoder().encodeToString("expected-key".getBytes()))
            .addToData("user.crt", Base64.getEncoder().encodeToString("expected-crt".getBytes()))
            .addToData("user.p12", Base64.getEncoder().encodeToString("expected-p12".getBytes()))
            .addToData("user.password", Base64.getEncoder().encodeToString("expected-password".getBytes()))
            .build();
}
 
Example #18
Source File: SecretAsContainerResourceProvisionerTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Test(
    expectedExceptions = InfrastructureException.class,
    expectedExceptionsMessageRegExp =
        "Unable to mount secret 'test_secret': it has missing or unknown type of the mount. Please make sure that 'che.eclipse.org/mount-as' annotation has value either 'env' or 'file'.")
public void shouldThrowExceptionWhenNoMountTypeSpecified() throws Exception {
  Secret secret =
      new SecretBuilder()
          .withData(ImmutableMap.of("settings.xml", "random", "another.xml", "freedom"))
          .withMetadata(
              new ObjectMetaBuilder()
                  .withName("test_secret")
                  .withAnnotations(emptyMap())
                  .withLabels(emptyMap())
                  .build())
          .build();
  when(secrets.get(any(LabelSelector.class))).thenReturn(singletonList(secret));
  provisioner.provision(environment, runtimeIdentity, namespace);
}
 
Example #19
Source File: PropagationPolicyTest.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("Should delete a Secret with specified PropagationPolicy")
void testDeleteSecretWithExplicitPropagationPolicy() throws InterruptedException {
  // Given
  server.expect().delete().withPath("/api/v1/namespaces/ns1/secrets/mysecret")
    .andReturn(HttpURLConnection.HTTP_OK, new SecretBuilder().build())
    .once();
  KubernetesClient client = server.getClient();

  // When
  Boolean isDeleted = client.secrets().inNamespace("ns1").withName("mysecret").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();

  // Then
  assertTrue(isDeleted);
  assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest());
}
 
Example #20
Source File: SecretUtils.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public static void createSecretFromFile(Map<String, String> certFilesPath, String name, String namespace, Map<String, String> labels) {
    byte[] encoded;
    try {
        Map<String, String> data = new HashMap<>();
        for (Map.Entry<String, String> entry : certFilesPath.entrySet()) {
            encoded = Files.readAllBytes(Paths.get(entry.getValue()));

            Base64.Encoder encoder = Base64.getEncoder();
            data.put(entry.getKey(), encoder.encodeToString(encoded));
        }

        Secret secret = new SecretBuilder()
            .withData(data)
                .withNewMetadata()
                    .withName(name)
                    .withNamespace(namespace)
                    .addToLabels(labels)
                .endMetadata()
            .build();
        kubeClient().namespace(namespace).createSecret(secret);

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #21
Source File: FileSecretApplierTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Test(
    expectedExceptions = InfrastructureException.class,
    expectedExceptionsMessageRegExp =
        "Unable to mount secret 'test_secret': It is configured to be mounted as a file but the mount path was not specified. Please define the 'che.eclipse.org/mount-path' annotation on the secret to specify it.")
public void shouldThrowExceptionWhenNoMountPathSpecifiedForFiles() throws Exception {
  Container container_match = new ContainerBuilder().withName("maven").build();

  PodSpec localSpec =
      new PodSpecBuilder().withContainers(ImmutableList.of(container_match)).build();

  when(podData.getSpec()).thenReturn(localSpec);
  Secret secret =
      new SecretBuilder()
          .withData(ImmutableMap.of("settings.xml", "random", "another.xml", "freedom"))
          .withMetadata(
              new ObjectMetaBuilder()
                  .withName("test_secret")
                  .withAnnotations(singletonMap(ANNOTATION_MOUNT_AS, "file"))
                  .withLabels(emptyMap())
                  .build())
          .build();
  when(secrets.get(any(LabelSelector.class))).thenReturn(singletonList(secret));
  secretApplier.applySecret(environment, runtimeIdentity, secret);
}
 
Example #22
Source File: Ca.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Set the {@code strimzi.io/force-renew} annotation on the given {@code caCert} if the given {@code caKey} has
 * the given {@code key}.
 *
 * This is used to force certificate renewal when upgrading from a Strimzi 0.6.0 Secret.
 */
protected static Secret forceRenewal(Secret caCert, Secret caKey, String key) {
    if (caCert != null && caKey != null && caKey.getData() != null && caKey.getData().containsKey(key)) {
        caCert = new SecretBuilder(caCert).editMetadata().addToAnnotations(ANNO_STRIMZI_IO_FORCE_RENEW, "true").endMetadata().build();
    }
    return caCert;
}
 
Example #23
Source File: KafkaAssemblyOperatorCustomCertTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
public Secret getExternalSecret() {
    return new SecretBuilder()
            .withNewMetadata()
                .withNewName("my-external-secret")
            .endMetadata()
            .addToData("tls.crt", "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQxVENDQXIyZ0F3SUJBZ0lVUWUrQUdacXdDK0Z0ZFBiMjUyQU1ERjlaOFk0d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1ZERUxNQWtHQTFVRUJoTUNRMW94RHpBTkJnTlZCQWNUQmxCeVlXZDFaVEViTUJrR0ExVUVDaE1TU21GcgpkV0lnVTJOb2IyeDZMQ0JKYm1NdU1SY3dGUVlEVlFRREV3NUpiblJsY20xbFpHbGhkR1ZEUVRBZUZ3MHhPVEV5Ck16RXhPVEl4TURCYUZ3MHlNREV4TWprd016SXhNREJhTUU0eEN6QUpCZ05WQkFZVEFrTmFNUTh3RFFZRFZRUUgKRX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ZnY09hMGsxeEhxVSt3VUxJWm9hcmlxWXhYUHMvcEU4ZHoralQ3Wld4WmI0aGJ1WmRrU2lJWWVWTzlpaGhKagpKbDZGdTRFWTlRS0JnUUN2S2tPL3J4UUhaK1g3eDEvZDNGUEJId3ZhSHNaYjZtWnBicWk2NHRYWFVDYmFQa2UzCjNGdTVBd2NhWHBLWTBKajQvUXliMXhUK3NWQVh5R0F1bENEUDNZdUxxcUNralFtZy9wekZSNWtZUlA0UDRTSDAKbU5ORERacGt2UVJnUGdmKzhwY2ZMVkNNSllSUEx4c2FOdWFoaE45NEtkaFVEbm9VZEloc1piOSszd0tCZ0d3cApBTGttQkc4WkZ3M2NUdlhDcS81RWpJdjllTGVnVjB5NUs4cHFKTktqa0NoWlRZN2swdHFaTU1XWC8xWnFmdmc5CnIvUEFrdEV3SHlnancwMWJFMU9Yd2dTdStIU3pYUGpIY1RQbjVVU21meGQ3NUsxVldXTDVpMmNqbUJYVkRlK1YKRFlJUmVnWTZrR00rUEpwbkdqRHovSWY0WlhyOGJIWmp5S3I3Y0tzbEFvR0JBTG1TbS8ydkptd21VTzJSQjZEQwpjb1ZrTEZLNkROUmhQaGw4c3NOdDRBWnA4YUJtVzloZC9TditWOHhoNzl6OGhPUlF5cjZoNDVVRjlySXhJb1kyCll3MllidkkyYzRiZlZEQWpGY3U3UEZ3MzVoOFJPRytrMStoNDZQUkhKY1F2dzJxSnN2NnhKOVZLaEdzcEQxdUgKeUVHOEQxRGtVM1FVOElTN01ybUR6Mk9YCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K")
            .build();
}
 
Example #24
Source File: CertificateRenewalTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testRenewalOfDeploymentCertificatesDelayedRenewalOutsideOfMaintenanceWindow() throws IOException {
    Secret initialSecret = new SecretBuilder()
            .withNewMetadata()
            .withNewName("test-secret")
            .endMetadata()
            .addToData("deployment.crt", Base64.getEncoder().encodeToString("old-cert".getBytes()))
            .addToData("deployment.key", Base64.getEncoder().encodeToString("old-key".getBytes()))
            .addToData("deployment.p12", Base64.getEncoder().encodeToString("old-keystore".getBytes()))
            .addToData("deployment.password", Base64.getEncoder().encodeToString("old-password".getBytes()))
            .build();

    CertAndKey newCertAndKey = new CertAndKey("new-key".getBytes(), "new-cert".getBytes(), "new-truststore".getBytes(), "new-keystore".getBytes(), "new-password");
    ClusterCa clusterCaMock = mock(ClusterCa.class);
    when(clusterCaMock.certRenewed()).thenReturn(false);
    when(clusterCaMock.isExpiring(any(), any())).thenReturn(true);
    when(clusterCaMock.generateSignedCert(anyString(), anyString())).thenReturn(newCertAndKey);
    String namespace = "my-namespace";
    String secretName = "my-secret";
    String commonName = "deployment";
    String keyCertName = "deployment";
    Labels labels = Labels.forStrimziCluster("my-cluster");
    OwnerReference ownerReference = new OwnerReference();
    boolean isMaintenanceTimeWindowsSatisfied = false;

    Secret newSecret = ModelUtils.buildSecret(clusterCaMock, initialSecret, namespace, secretName, commonName,
            keyCertName, labels, ownerReference, isMaintenanceTimeWindowsSatisfied);

    assertThat(newSecret.getData(), hasEntry("deployment.crt", Base64.getEncoder().encodeToString("old-cert".getBytes())));
    assertThat(newSecret.getData(), hasEntry("deployment.key", Base64.getEncoder().encodeToString("old-key".getBytes())));
    assertThat(newSecret.getData(), hasEntry("deployment.p12", Base64.getEncoder().encodeToString("old-keystore".getBytes())));
    assertThat(newSecret.getData(), hasEntry("deployment.password", Base64.getEncoder().encodeToString("old-password".getBytes())));
}
 
Example #25
Source File: KafkaAssemblyOperatorCustomCertTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
public Secret getTlsSecret() {
    return new SecretBuilder()
            .withNewMetadata()
                .withNewName("my-tls-secret")
            .endMetadata()
            .addToData("tls.crt", "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVVekNDQXp1Z0F3SUJBZ0lVZWlqTU02TVBIazB3R24xV3FtL3o4ZTNkYUpJd0RRWUpLb1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2JBck1OLzMzZytZdjhzcVl4dHh3S0JnRVYzdWprbjJQSmtPMEVlWTBZNQpYSFR2UFVzS3BNMlZRend1aXBmemFrT2pCYkg4bWlmUkJFOFR4TDZCVFlSc3crbGFYVXcxbEQ4aWJDNmRuZFRvCldWRWM3Z2kzRlh1RjBUV3p2K2dIbnFCZWFwbWdxOGE4TEhqVHRFMDNnVmo0aG1vZHJIbkVEZ3J5ajlsc0sxck0KYnp6RTlkcWdrNU5CL0c4QmwvTlJnd01BCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K")
            .build();
}
 
Example #26
Source File: FileSecretApplierTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void shouldNotProvisionAllContainersifAutomountDisabled() throws Exception {
  Container container_match1 = spy(new ContainerBuilder().withName("maven").build());
  Container container_match2 = spy(new ContainerBuilder().withName("other").build());

  when(podSpec.getContainers()).thenReturn(ImmutableList.of(container_match1, container_match2));

  Secret secret =
      new SecretBuilder()
          .withData(singletonMap("foo", "random"))
          .withMetadata(
              new ObjectMetaBuilder()
                  .withName("test_secret")
                  .withAnnotations(
                      ImmutableMap.of(
                          ANNOTATION_MOUNT_AS,
                          "file",
                          ANNOTATION_MOUNT_PATH,
                          "/home/user/.m2",
                          ANNOTATION_AUTOMOUNT,
                          "false"))
                  .withLabels(emptyMap())
                  .build())
          .build();

  secretApplier.applySecret(environment, runtimeIdentity, secret);

  verify(container_match1).getName();
  verify(container_match2).getName();
  // both containers no actions
  verifyNoMoreInteractions(container_match1, container_match2);
}
 
Example #27
Source File: KafkaUserModel.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates secret with the data
 * @param data Map with the Secret content
 * @return The secret.
 */
protected Secret createSecret(Map<String, String> data) {
    Secret s = new SecretBuilder()
            .withNewMetadata()
                .withName(getSecretName())
                .withNamespace(namespace)
                .withLabels(labels.toMap())
                .withOwnerReferences(createOwnerReference())
            .endMetadata()
            .withData(data)
            .build();

    return s;
}
 
Example #28
Source File: KafkaAssemblyOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource("data")
public void testCreateClusterWithJmxTrans(Params params, VertxTestContext context) {
    setFields(params);
    Kafka kafka = getKafkaAssembly("foo");
    kafka.getSpec()
            .getKafka().setJmxOptions(new KafkaJmxOptionsBuilder()
            .withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build())
            .build());

    kafka.getSpec().setJmxTrans(new JmxTransSpecBuilder()
            .withKafkaQueries(new JmxTransQueryTemplateBuilder()
                    .withNewTargetMBean("mbean")
                    .withAttributes("attribute")
                    .withOutputs("output")
                    .build())
            .withOutputDefinitions(new JmxTransOutputDefinitionTemplateBuilder()
                    .withOutputType("host")
                    .withName("output")
                    .build())
            .build());

    createCluster(context, kafka, Collections.singletonList(new SecretBuilder()
            .withNewMetadata()
            .withName(KafkaCluster.jmxSecretName("foo"))
            .withNamespace("test")
            .endMetadata()
            .withData(Collections.singletonMap("foo", "bar"))
            .build()
    ));
}
 
Example #29
Source File: OpenShiftEnvironmentFactoryTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void addSecretsWhenRecipeContainsThem() throws Exception {
  Secret secret =
      new SecretBuilder().withNewMetadata().withName("test-secret").endMetadata().build();
  when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(secret));

  final OpenShiftEnvironment parsed =
      osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());

  assertEquals(parsed.getSecrets().size(), 1);
  assertEquals(
      parsed.getSecrets().get("test-secret").getMetadata().getName(),
      secret.getMetadata().getName());
}
 
Example #30
Source File: SecretOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Override
protected Secret resource() {
    return new SecretBuilder()
            .withNewMetadata()
            .withName(RESOURCE_NAME)
            .withNamespace(NAMESPACE)
            .withLabels(singletonMap("foo", "bar"))
            .endMetadata()
            .withData(singletonMap("FOO", "BAR"))
            .build();
}