예제 #1
0
        public async Task ShouldKeepCurrentTokenParamsAndOptionsEvenIfCurrentTokenIsValidAndNoNewTokenIsRequested()
        {
            var client = GetRestClient(null,
                                       opts => opts.TokenDetails = new TokenDetails("boo")
            {
                Expires = Now.AddHours(10)
            });

            var testAblyAuth      = new TestAblyAuth(client.Options, client);
            var customTokenParams = new TokenParams()
            {
                Ttl = TimeSpan.FromHours(2), Timestamp = Now.AddHours(1)
            };
            var customAuthOptions = new AuthOptions()
            {
                UseTokenAuth = true
            };

            await testAblyAuth.AuthoriseAsync(customTokenParams, customAuthOptions);

            var expectedTokenParams = customTokenParams.Clone();

            expectedTokenParams.Timestamp = null;
            testAblyAuth.CurrentTokenParams.ShouldBeEquivalentTo(expectedTokenParams);
            testAblyAuth.CurrentAuthOptions.Should().BeSameAs(customAuthOptions);
            testAblyAuth.CurrentAuthOptions.Force.Should().BeFalse();
        }
예제 #2
0
        public async Task ShouldKeepTokenParamsAndAuthOptionsExcetpForceAndCurrentTimestamp()
        {
            var client            = GetRestClient();
            var testAblyAuth      = new TestAblyAuth(client.Options, client);
            var customTokenParams = new TokenParams()
            {
                Ttl = TimeSpan.FromHours(2), Timestamp = Now.AddHours(1)
            };
            var customAuthOptions = new AuthOptions()
            {
                UseTokenAuth = true, Force = true
            };

            await testAblyAuth.AuthoriseAsync(customTokenParams, customAuthOptions);

            var expectedTokenParams = customTokenParams.Clone();

            expectedTokenParams.Timestamp = null;
            testAblyAuth.CurrentTokenParams.ShouldBeEquivalentTo(expectedTokenParams);

            testAblyAuth.CurrentAuthOptions.Should().BeSameAs(customAuthOptions);
            testAblyAuth.CurrentTokenParams.Timestamp.Should().Be(null);
            testAblyAuth.CurrentAuthOptions.Force.Should().BeFalse();
        }