Search in sources :

Example 11 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullNotAfterUtcSigningCert.

// SRS_RegistrationOperationStatusParser_25_019: [ This method shall throw IllegalArgumentException if Not before UTC time from X509 Signing Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullNotAfterUtcSigningCert() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 12 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullIssuerNameSigningCert.

// SRS_RegistrationOperationStatusParser_25_015: [ This method shall throw IllegalArgumentException if Issuer Name from X509 Signing Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullIssuerNameSigningCert() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 13 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullSha1Thumbprint.

// SRS_RegistrationOperationStatusParser_25_009: [ This method shall throw IllegalArgumentException if Sha1 Thumbprint from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullSha1Thumbprint() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 14 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullSubjectName.

// SRS_RegistrationOperationStatusParser_25_008: [ This method shall throw IllegalArgumentException if Subject Name from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullSubjectName() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{" + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 15 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullNotBeforeUtcSigningCert.

// SRS_RegistrationOperationStatusParser_25_020: [ This method shall throw IllegalArgumentException if Not After UTC  from X509 Signing Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullNotBeforeUtcSigningCert() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Aggregations

RegistrationOperationStatusParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser)31 Test (org.junit.Test)27 ProvisioningDeviceClientAuthenticationException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientAuthenticationException)2 ProvisioningDeviceClientException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException)2 ProvisioningDeviceHubException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceHubException)1 DeviceRegistrationResultParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.DeviceRegistrationResultParser)1 SecurityProviderTpm (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderTpm)1 SecurityProviderX509 (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderX509)1 SecurityProviderException (com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException)1