use of com.microsoft.azure.sdk.iot.device.auth.Signature in project azure-iot-sdk-java by Azure.
the class SignatureTest method toStringReturnsCorrectString.
// Tests_SRS_SIGNATURE_11_005: [The function shall return the string representation of the signature.]
@Test
public void toStringReturnsCorrectString() {
final String resourceUri = "test-resource-uri";
final String deviceKey = "test-device-key";
final long expiryTime = 101L;
final String sigStr = "test-signature";
new Expectations() {
{
// this should be the last step of the signature computation.
SignatureHelper.encodeSignatureWebSafe(anyString);
result = sigStr;
}
};
Signature sig = new Signature(resourceUri, expiryTime, deviceKey);
String testSigStr = sig.toString();
final String expectedSigStr = sigStr;
assertThat(testSigStr, is(expectedSigStr));
}
use of com.microsoft.azure.sdk.iot.device.auth.Signature in project azure-iot-sdk-java by Azure.
the class SignatureIT method signatureIsCorrect.
@Test
public void signatureIsCorrect() {
String resourceUri = "sdktesthub.private.azure-devices-int.net/devices/test8";
String deviceKey = "q+DKVojmMz014RjAwpNGZbAkdOocSVWMKPOccLfUmLE=";
long expiryTime = 1462333672;
String testSig = new Signature(resourceUri, expiryTime, deviceKey).toString();
String expectedSigUpperHex = "ZrTYgp6uRmbDl4lzzewxFD9FoaNKIK7G2bdivDbtc9A%3D";
String expectedSigLowerHex = "ZrTYgp6uRmbDl4lzzewxFD9FoaNKIK7G2bdivDbtc9A%3d";
assertThat(testSig, is(anyOf(equalTo(expectedSigUpperHex), equalTo(expectedSigLowerHex))));
}
Aggregations