Exemplo n.º 1
0
        public void ToStringReflectsTheValue()
        {
            var expected  = "This is the value of the SAS";
            var signature = new SettablePropertiesMock(value: expected);

            Assert.That(signature.ToString(), Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void GetTokenIgnoresScopeAndCancellationToken()
        {
            var value      = "TOkEn!";
            var signature  = new SettablePropertiesMock(value: value);
            var credential = new SharedAccessSignatureCredential(signature);

            Assert.That(credential.GetToken(new[] { "test", "this" }, CancellationToken.None), Is.SameAs(signature.Value), "The credential should return the signature as the token.");
        }
Exemplo n.º 3
0
        public void GetTokenReturnsTheSignatureValue()
        {
            var value      = "TOkEn!";
            var signature  = new SettablePropertiesMock(value: value);
            var credential = new SharedAccessSignatureCredential(signature);

            Assert.That(credential.GetToken(null, default), Is.SameAs(signature.Value), "The credential should return the signature as the token.");
        }
Exemplo n.º 4
0
        public async Task GetTokenAsyncIgnoresScopeAndCancellationToken()
        {
            var value        = "TOkEn!";
            var signature    = new SettablePropertiesMock(value: value);
            var credential   = new SharedAccessSignatureCredential(signature);
            var cancellation = new CancellationTokenSource();
            var token        = await credential.GetTokenAsync(new string[0], cancellation.Token);

            Assert.That(token, Is.SameAs(signature.Value), "The credential should return the signature as the token.");
        }
Exemplo n.º 5
0
        public void ConstructorValidatesInitializesProperties()
        {
            var expiration = DateTime.UtcNow;
            var audience   = "the-audience";
            var value      = "TOkEn!";
            var signature  = new SettablePropertiesMock("keyName", "key", expiration, audience, value);
            var credential = new SharedAccessSignatureCredential(signature);

            Assert.That(credential.SharedAccessSignature, Is.SameAs(signature), "The credential should allow the signature to be accessed.");
        }
Exemplo n.º 6
0
        public void ConstructorValidatesInitializesProperties()
        {
            var expiration = DateTime.UtcNow;
            var audience   = "the-audience";
            var value      = "TOkEn!";
            var signature  = new SettablePropertiesMock("keyName", "key", expiration, audience, value);
            var token      = new TrackOneSharedAccessSignatureToken(signature);

            Assert.That(token.Audience, Is.EqualTo(audience), "The audience for the token should match the signature resource.");
            Assert.That(token.TokenValue, Is.EqualTo(value), "The value for the token should match the signature value.");
            Assert.That(token.ExpiresAtUtc, Is.EqualTo(expiration), "The expiration for the token should match the signature expiration.");
            Assert.That(token.TokenType, Is.EqualTo(ClientConstants.SasTokenType), "The type for the token should match the expected constant.");
        }
Exemplo n.º 7
0
        public void ConstructorValidatesTheSignatureResource()
        {
            var signature = new SettablePropertiesMock("keyName", "key", DateTime.UtcNow, "", "token!");

            Assert.That(() => new TrackOneSharedAccessSignatureToken(signature), Throws.InstanceOf <ArgumentException>());
        }