Search in sources :

Example 6 with X509CertificateWithInfo

use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo in project azure-iot-sdk-java by Azure.

the class X509CertificatesTest method constructorCopiesPrimaryAndSecondaryCertsSucceed.

/* SRS_X509_CERTIFICATES_21_006: [If the secondary certificate is not null, the constructor shall create a new instance of the X509CertificateWithInfo using the provided secondary certificate, and store it as the secondary Certificate.] */
@Test
public void constructorCopiesPrimaryAndSecondaryCertsSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
    // arrange
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, PUBLIC_CERTIFICATE_STRING);
    // act
    X509Certificates x509CertificatesCopy = new X509Certificates(x509Certificates);
    // assert
    assertNotNull(Deencapsulation.getField(x509CertificatesCopy, "primary"));
    assertNotNull(Deencapsulation.getField(x509CertificatesCopy, "secondary"));
    new Verifications() {

        {
            new X509CertificateWithInfo((X509CertificateWithInfo) any);
            times = 2;
        }
    };
}
Also used : X509CertificateWithInfo(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo) X509Certificates(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 7 with X509CertificateWithInfo

use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo in project azure-iot-sdk-java by Azure.

the class X509CertificateWithInfoTest method constructorCopyCertificate.

/* SRS_X509_CERTIFICATE_WITH_INFO_21_004: [The constructor shall copy the certificate form the provided x509CertificateWithInfo.] */
@Test
public void constructorCopyCertificate() {
    // arrange
    X509CertificateWithInfo x509CertificateWithInfo = Deencapsulation.newInstance(X509CertificateWithInfo.class, new Class[] { String.class }, PUBLIC_CERTIFICATE_STRING);
    // act
    X509CertificateWithInfo x509CertificateWithInfoCopy = new X509CertificateWithInfo(x509CertificateWithInfo);
    // assert
    assertEquals(PUBLIC_CERTIFICATE_STRING, Deencapsulation.getField(x509CertificateWithInfoCopy, "certificate"));
    assertNull(Deencapsulation.getField(x509CertificateWithInfoCopy, "info"));
}
Also used : X509CertificateWithInfo(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo) Test(org.junit.Test)

Example 8 with X509CertificateWithInfo

use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo in project azure-iot-sdk-java by Azure.

the class X509CertificateWithInfoTest method constructorCopyInfo.

/* SRS_X509_CERTIFICATE_WITH_INFO_21_005: [If the provide x509CertificateWithInfo contains `info`, the constructor shall create a new instance of the X509CertificateInfo with the provided `info`.] */
@Test
public void constructorCopyInfo(@Mocked final X509CertificateInfo mockedX509CertificateInfo) throws IllegalArgumentException {
    // arrange
    X509CertificateWithInfo x509CertificateWithInfo = Deencapsulation.newInstance(X509CertificateWithInfo.class);
    Deencapsulation.setField(x509CertificateWithInfo, "info", mockedX509CertificateInfo);
    // act
    X509CertificateWithInfo x509CertificateWithInfoCopy = new X509CertificateWithInfo(x509CertificateWithInfo);
    // assert
    assertNull(Deencapsulation.getField(x509CertificateWithInfoCopy, "certificate"));
    assertNotNull(Deencapsulation.getField(x509CertificateWithInfoCopy, "info"));
}
Also used : X509CertificateWithInfo(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo) Test(org.junit.Test)

Aggregations

X509CertificateWithInfo (com.microsoft.azure.sdk.iot.provisioning.service.configs.X509CertificateWithInfo)8 Test (org.junit.Test)8 X509Certificates (com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates)2 Verifications (mockit.Verifications)2