use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.
the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullNotAfterUtc.
// SRS_RegistrationOperationStatusParser_25_011: [ This method shall throw IllegalArgumentException if NotBeforeUtc from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullNotAfterUtc() 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\"," + "\"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);
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.
the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullVersion.
// SRS_RegistrationOperationStatusParser_25_014: [ This method shall throw IllegalArgumentException if version from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullVersion() 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 + "\"" + "}," + "\"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);
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.
the class RegistrationOperationStatusParserTest method constructorWithTPMJsonSucceed.
// SRS_DeviceRegistrationResultParser_25_008: [ This method shall return the parsed TpmRegistrationResultParser Object. ]
// SRS_RegistrationOperationStatusParser_25_023: [ This method shall return operationId. ]
// SRS_RegistrationOperationStatusParser_25_024: [ This method shall return status . ]
// SRS_RegistrationOperationStatusParser_25_025: [ This method shall return DeviceRegistrationResultParser Object. ]
@Test
public void constructorWithTPMJsonSucceed() throws IllegalArgumentException {
final String json = "" + "{" + "\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{" + "\"tpm\":{" + "\"authenticationKey\":\"" + TEST_AUTH_KEY + "\"" + "}," + "\"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);
assertNotNull(operationsRegistrationOperationStatusParser.getOperationId());
assertEquals(TEST_OPERATION_ID, operationsRegistrationOperationStatusParser.getOperationId());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getRegistrationId());
assertEquals(TEST_REGISTRATION_ID, operationsRegistrationOperationStatusParser.getRegistrationState().getRegistrationId());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getCreatedDateTimeUtc());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getAssignedHub());
assertEquals(TEST_ASSIGNED_HUB, operationsRegistrationOperationStatusParser.getRegistrationState().getAssignedHub());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getDeviceId());
assertEquals(TEST_DEVICE_ID, operationsRegistrationOperationStatusParser.getRegistrationState().getDeviceId());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getStatus());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getEtag());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getLastUpdatesDateTimeUtc());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getTpm());
assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getTpm().getAuthenticationKey());
assertEquals(TEST_AUTH_KEY, operationsRegistrationOperationStatusParser.getRegistrationState().getTpm().getAuthenticationKey());
assertNotNull(operationsRegistrationOperationStatusParser.getStatus());
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.
the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullSha256Thumbprint.
// SRS_RegistrationOperationStatusParser_25_010: [ This method shall throw IllegalArgumentException if SHA256 Thumbprint from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullSha256Thumbprint() throws IllegalArgumentException, JsonParseException {
final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_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);
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.
the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullSerialNumber.
// SRS_RegistrationOperationStatusParser_25_013: [ This method shall throw IllegalArgumentException if Serial Number from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullSerialNumber() 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\"," + "\"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);
}
Aggregations