Search in sources :

Example 1 with X509Certificates

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

the class X509CertificatesTest method constructorStorePrimaryAndSecondaryCertsSucceed.

/* SRS_X509_CERTIFICATES_21_003: [If the secondary certificate is not null or empty, 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 constructorStorePrimaryAndSecondaryCertsSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
    // arrange
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(X509CertificateWithInfo.class, new Class[] { String.class }, PUBLIC_CERTIFICATE_STRING);
            result = mockedX509CertificateWithInfo;
            times = 2;
        }
    };
    // act
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, PUBLIC_CERTIFICATE_STRING);
    // assert
    assertNotNull(Deencapsulation.getField(x509Certificates, "primary"));
    assertNotNull(Deencapsulation.getField(x509Certificates, "secondary"));
}
Also used : X509Certificates(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 2 with X509Certificates

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

the class X509CertificatesTest method emptyConstructorSucceed.

/* SRS_X509_CERTIFICATES_21_009: [The X509Certificates shall provide an empty constructor to make GSON happy.] */
@Test
public void emptyConstructorSucceed() {
    // arrange
    // act
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class);
    // assert
    assertNotNull(x509Certificates);
}
Also used : X509Certificates(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates) Test(org.junit.Test)

Example 3 with X509Certificates

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

the class X509CertificatesTest method constructorStorePrimaryCertSucceed.

/* SRS_X509_CERTIFICATES_21_002: [The constructor shall create a new instance of the X509CertificateWithInfo using the provided primary certificate, and store is as the primary Certificate.] */
/* SRS_X509_CERTIFICATES_21_003: [If the secondary certificate is not null or empty, 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 constructorStorePrimaryCertSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
    // arrange
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(X509CertificateWithInfo.class, new Class[] { String.class }, PUBLIC_CERTIFICATE_STRING);
            result = mockedX509CertificateWithInfo;
            times = 1;
        }
    };
    // act
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, null);
    // assert
    assertNotNull(Deencapsulation.getField(x509Certificates, "primary"));
    assertNull(Deencapsulation.getField(x509Certificates, "secondary"));
}
Also used : X509Certificates(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 4 with X509Certificates

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

the class X509CertificatesTest method constructorCopyThrowsOnPrimaryCertNull.

/* SRS_X509_CERTIFICATES_21_004: [The constructor shall throw IllegalArgumentException if the provide X509Certificates is null or if its primary certificate is null.] */
@Test(expected = IllegalArgumentException.class)
public void constructorCopyThrowsOnPrimaryCertNull() throws IllegalArgumentException {
    // arrange
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class);
    // act
    new X509Certificates(x509Certificates);
// assert
}
Also used : X509Certificates(com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates) Test(org.junit.Test)

Example 5 with X509Certificates

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

the class X509CertificatesTest method constructorCopiesPrimaryCertSucceed.

/* SRS_X509_CERTIFICATES_21_005: [The constructor shall create a new instance of X509CertificateWithInfo using the primary certificate on the provided x509Certificates.] */
/* 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 constructorCopiesPrimaryCertSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
    // arrange
    X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, null);
    // act
    X509Certificates x509CertificatesCopy = new X509Certificates(x509Certificates);
    // assert
    assertNotNull(Deencapsulation.getField(x509CertificatesCopy, "primary"));
    assertNull(Deencapsulation.getField(x509CertificatesCopy, "secondary"));
    new Verifications() {

        {
            new X509CertificateWithInfo((X509CertificateWithInfo) any);
            times = 1;
        }
    };
}
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)

Aggregations

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