@@ -589,10 +589,12 @@ public void constructor_HmacAuthEnabledButNoSecretKeyGiven_ShouldCreateConfigPro
589
589
throws IOException {
590
590
// Arrange
591
591
Properties props = new Properties ();
592
- props .put (ClientConfig .ENTITY_ID , SOME_ENTITY_ID );
592
+ props .put (ClientConfig .CERT_VERSION , "0" );
593
593
props .put (ClientConfig .CERT_HOLDER_ID , SOME_CERT_HOLDER_ID );
594
594
props .put (ClientConfig .CERT_PEM , SOME_CERT_PEM );
595
595
props .put (ClientConfig .PRIVATE_KEY_PEM , SOME_PRIVATE_KEY_PEM );
596
+ props .put (ClientConfig .ENTITY_ID , SOME_ENTITY_ID );
597
+ props .put (ClientConfig .DS_CERT_VERSION , SOME_CERT_VERSION );
596
598
props .put (ClientConfig .DS_CERT_PEM , SOME_CERT_PEM + "New" );
597
599
props .put (ClientConfig .DS_PRIVATE_KEY_PEM , SOME_PRIVATE_KEY_PEM + "New" );
598
600
@@ -601,6 +603,8 @@ public void constructor_HmacAuthEnabledButNoSecretKeyGiven_ShouldCreateConfigPro
601
603
602
604
// Assert
603
605
assertThat (config .getDigitalSignatureIdentityConfig ().getEntityId ()).isEqualTo (SOME_ENTITY_ID );
606
+ assertThat (config .getDigitalSignatureIdentityConfig ().getCertVersion ())
607
+ .isEqualTo (Integer .parseInt (SOME_CERT_VERSION ));
604
608
assertThat (config .getDigitalSignatureIdentityConfig ().getCert ())
605
609
.isEqualTo (SOME_CERT_PEM + "New" );
606
610
assertThat (config .getDigitalSignatureIdentityConfig ().getPrivateKey ())
@@ -740,4 +744,59 @@ public void constructor_DifferentClientConfigGiven_ShouldReturnNonEqualConfigs()
740
744
assertThat (config1 .getLedgerTargetConfig ()).isNotEqualTo (config2 .getLedgerTargetConfig ());
741
745
assertThat (config1 .getAuditorTargetConfig ()).isNotEqualTo (config2 .getAuditorTargetConfig ());
742
746
}
747
+
748
+ @ Test
749
+ public void constructor_CertVersionZeroGiven_ShouldThrowIllegalArgumentException () {
750
+ // Arrange
751
+ Properties props = new Properties ();
752
+ props .put (ClientConfig .ENTITY_ID , SOME_CERT_HOLDER_ID );
753
+ props .put (ClientConfig .DS_CERT_VERSION , "0" );
754
+ props .put (ClientConfig .DS_CERT_PEM , SOME_CERT_PEM );
755
+ props .put (ClientConfig .DS_PRIVATE_KEY_PEM , SOME_PRIVATE_KEY_PEM );
756
+
757
+ // Act Assert
758
+ assertThatThrownBy (() -> new ClientConfig (props )).isInstanceOf (IllegalArgumentException .class );
759
+ }
760
+
761
+ @ Test
762
+ public void constructor_DeprecatedCertVersionZeroGiven_ShouldThrowIllegalArgumentException () {
763
+ // Arrange
764
+ Properties props = new Properties ();
765
+ props .put (ClientConfig .CERT_HOLDER_ID , SOME_CERT_HOLDER_ID );
766
+ props .put (ClientConfig .CERT_VERSION , "0" );
767
+ props .put (ClientConfig .CERT_PEM , SOME_CERT_PEM );
768
+ props .put (ClientConfig .PRIVATE_KEY_PEM , SOME_PRIVATE_KEY_PEM );
769
+
770
+ // Act Assert
771
+ assertThatThrownBy (() -> new ClientConfig (props )).isInstanceOf (IllegalArgumentException .class );
772
+ }
773
+
774
+ @ Test
775
+ public void
776
+ constructor_NewWrongCertVersionAndDeprecatedCorrectCertVersionGiven_ShouldThrowIllegalArgumentException () {
777
+ // Arrange
778
+ Properties props = new Properties ();
779
+ props .put (ClientConfig .ENTITY_ID , SOME_CERT_HOLDER_ID );
780
+ props .put (ClientConfig .DS_CERT_VERSION , "0" );
781
+ props .put (ClientConfig .DS_CERT_PEM , SOME_CERT_PEM );
782
+ props .put (ClientConfig .DS_PRIVATE_KEY_PEM , SOME_PRIVATE_KEY_PEM );
783
+ props .put (ClientConfig .CERT_HOLDER_ID , SOME_CERT_HOLDER_ID );
784
+ props .put (ClientConfig .CERT_VERSION , SOME_CERT_VERSION );
785
+
786
+ // Act Assert
787
+ assertThatThrownBy (() -> new ClientConfig (props )).isInstanceOf (IllegalArgumentException .class );
788
+ }
789
+
790
+ @ Test
791
+ public void constructor_SecretVersionZeroGiven_ShouldThrowIllegalArgumentException () {
792
+ // Arrange
793
+ Properties props = new Properties ();
794
+ props .put (ClientConfig .ENTITY_ID , SOME_ENTITY_ID );
795
+ props .put (ClientConfig .AUTHENTICATION_METHOD , AuthenticationMethod .HMAC .getMethod ());
796
+ props .put (ClientConfig .HMAC_SECRET_KEY , SOME_SECRET_KEY );
797
+ props .put (ClientConfig .HMAC_SECRET_KEY_VERSION , "0" );
798
+
799
+ // Act Assert
800
+ assertThatThrownBy (() -> new ClientConfig (props )).isInstanceOf (IllegalArgumentException .class );
801
+ }
743
802
}
0 commit comments