-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove certificate logic from ModelUtils class.
Signed-off-by: Katherine Stanley <[email protected]>
- Loading branch information
Showing
24 changed files
with
389 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
certificate-manager/src/test/java/io/strimzi/certs/SecretCertProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.strimzi.certs; | ||
|
||
import io.fabric8.kubernetes.api.model.Secret; | ||
import io.fabric8.kubernetes.api.model.SecretBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class SecretCertProviderTest { | ||
|
||
@Test | ||
public void testExistingCertificatesDiffer() { | ||
Secret defaultSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.addToData("my-cluster-kafka-1.crt", "Certificate1") | ||
.addToData("my-cluster-kafka-1.key", "Key1") | ||
.addToData("my-cluster-kafka-2.crt", "Certificate2") | ||
.addToData("my-cluster-kafka-2.key", "Key2") | ||
.build(); | ||
|
||
Secret sameAsDefaultSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.addToData("my-cluster-kafka-1.crt", "Certificate1") | ||
.addToData("my-cluster-kafka-1.key", "Key1") | ||
.addToData("my-cluster-kafka-2.crt", "Certificate2") | ||
.addToData("my-cluster-kafka-2.key", "Key2") | ||
.build(); | ||
|
||
Secret scaleDownSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.build(); | ||
|
||
Secret scaleUpSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.addToData("my-cluster-kafka-1.crt", "Certificate1") | ||
.addToData("my-cluster-kafka-1.key", "Key1") | ||
.addToData("my-cluster-kafka-2.crt", "Certificate2") | ||
.addToData("my-cluster-kafka-2.key", "Key2") | ||
.addToData("my-cluster-kafka-3.crt", "Certificate3") | ||
.addToData("my-cluster-kafka-3.key", "Key3") | ||
.addToData("my-cluster-kafka-4.crt", "Certificate4") | ||
.addToData("my-cluster-kafka-4.key", "Key4") | ||
.build(); | ||
|
||
Secret changedSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.addToData("my-cluster-kafka-1.crt", "Certificate1") | ||
.addToData("my-cluster-kafka-1.key", "NewKey1") | ||
.addToData("my-cluster-kafka-2.crt", "Certificate2") | ||
.addToData("my-cluster-kafka-2.key", "Key2") | ||
.build(); | ||
|
||
Secret changedScaleUpSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "Certificate0") | ||
.addToData("my-cluster-kafka-0.key", "Key0") | ||
.addToData("my-cluster-kafka-1.crt", "Certificate1") | ||
.addToData("my-cluster-kafka-1.key", "Key1") | ||
.addToData("my-cluster-kafka-2.crt", "NewCertificate2") | ||
.addToData("my-cluster-kafka-2.key", "Key2") | ||
.addToData("my-cluster-kafka-3.crt", "Certificate3") | ||
.addToData("my-cluster-kafka-3.key", "Key3") | ||
.addToData("my-cluster-kafka-4.crt", "Certificate4") | ||
.addToData("my-cluster-kafka-4.key", "Key4") | ||
.build(); | ||
|
||
Secret changedScaleDownSecret = new SecretBuilder() | ||
.withNewMetadata() | ||
.withName("my-secret") | ||
.endMetadata() | ||
.addToData("my-cluster-kafka-0.crt", "NewCertificate0") | ||
.addToData("my-cluster-kafka-0.key", "NewKey0") | ||
.build(); | ||
|
||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, defaultSecret), is(false)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, sameAsDefaultSecret), is(false)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, scaleDownSecret), is(false)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, scaleUpSecret), is(false)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, changedSecret), is(true)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, changedScaleUpSecret), is(true)); | ||
assertThat(SecretCertProvider.doExistingCertificatesDiffer(defaultSecret, changedScaleDownSecret), is(true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.