Search in sources :

Example 1 with Signature

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));
}
Also used : Expectations(mockit.Expectations) Signature(com.microsoft.azure.sdk.iot.device.auth.Signature) Test(org.junit.Test)

Example 2 with Signature

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))));
}
Also used : Signature(com.microsoft.azure.sdk.iot.device.auth.Signature) Test(org.junit.Test)

Aggregations

Signature (com.microsoft.azure.sdk.iot.device.auth.Signature)2 Test (org.junit.Test)2 Expectations (mockit.Expectations)1