コード例 #1
0
        public async Task X509ManualProvision()
        {
            CancellationToken token = this.TestToken;

            await this.runtime.DeployConfigurationAsync(token);

            string leafDeviceId =
                IdentityLimits.CheckLeafId($"{Context.Current.DeviceId}-x509-quickstart-certs");

            var leaf = await LeafDevice.CreateAsync(
                leafDeviceId,
                Protocol.Amqp,
                AuthenticationType.Sas,
                Option.Some(Context.Current.DeviceId + "-x509"),
                false,
                CertificateAuthority.GetQuickstart(),
                this.iotHub,
                token);

            await TryFinally.DoAsync(
                async() =>
            {
                DateTime seekTime = DateTime.Now;
                await leaf.SendEventAsync(token);
                await leaf.WaitForEventsReceivedAsync(seekTime, token);
                await leaf.InvokeDirectMethodAsync(token);
            },
                async() =>
            {
                await leaf.DeleteIdentityAsync(token);
            });
        }
コード例 #2
0
        public async Task TransparentGateway(
            [Values] TestAuthenticationType testAuth,
            [Values(Protocol.Mqtt, Protocol.Amqp)] Protocol protocol)
        {
            if (!OsPlatform.IsWindows() && (protocol == Protocol.Amqp))
            {
                switch (testAuth)
                {
                case TestAuthenticationType.SelfSignedPrimary:
                case TestAuthenticationType.SelfSignedSecondary:
                case TestAuthenticationType.CertificateAuthority:
                    Assert.Ignore("Skipping the test case due to BUG 5234369");
                    break;

                default:
                    // Intentionally left blank
                    break;
                }
            }

            CancellationToken token = this.TestToken;

            string leafDeviceId = IdentityLimits.CheckLeafId(
                $"{Context.Current.DeviceId}-{protocol}-{testAuth}");

            Option <string> parentId = testAuth == TestAuthenticationType.SasOutOfScope
                ? Option.None <string>()
                : Option.Some(Context.Current.DeviceId.ToString());

            var leaf = await LeafDevice.CreateAsync(
                leafDeviceId,
                protocol,
                testAuth.ToAuthenticationType(),
                parentId,
                testAuth.UseSecondaryCertificate(),
                this.ca,
                this.iotHub,
                token);

            await TryFinally.DoAsync(
                async() =>
            {
                DateTime seekTime = DateTime.Now;
                await leaf.SendEventAsync(token);
                await leaf.WaitForEventsReceivedAsync(seekTime, token);
                await leaf.InvokeDirectMethodAsync(token);
            },
                async() =>
            {
                await leaf.DeleteIdentityAsync(token);
            });
        }
コード例 #3
0
        public async Task TransparentGateway(
            [Values] TestAuthenticationType testAuth,
            [Values(Protocol.Mqtt, Protocol.Amqp)] Protocol protocol)
        {
            CancellationToken token = this.TestToken;

            string leafDeviceId = IdentityLimits.CheckLeafId(
                $"{Context.Current.DeviceId}-{protocol}-{testAuth}");

            Option <string> parentId = testAuth == TestAuthenticationType.SasOutOfScope
                ? Option.None <string>()
                : Option.Some(Context.Current.DeviceId.ToString());

            var leaf = await LeafDevice.CreateAsync(
                leafDeviceId,
                protocol,
                testAuth.ToAuthenticationType(),
                parentId,
                testAuth.UseSecondaryCertificate(),
                this.ca,
                this.iotHub,
                token);

            await TryFinally.DoAsync(
                async() =>
            {
                DateTime seekTime = DateTime.Now;
                await leaf.SendEventAsync(token);
                await leaf.WaitForEventsReceivedAsync(seekTime, token);
                await leaf.InvokeDirectMethodAsync(token);
            },
                async() =>
            {
                await leaf.DeleteIdentityAsync(token);
            });
        }