示例#1
0
        public async Task TlsBasicEndToEnd()
        {
            TestCluster testCluster = default;

            try
            {
                var builder = new TestClusterBuilder()
                              .AddSiloBuilderConfigurator <TlsConfigurator>()
                              .AddClientBuilderConfigurator <TlsConfigurator>();

                var certificate = TestCertificateHelper.CreateSelfSignedCertificate(
                    CertificateSubjectName,
                    new[] { TestCertificateHelper.ClientAuthenticationOid, TestCertificateHelper.ServerAuthenticationOid });
                var encodedCertificate = TestCertificateHelper.ConvertToBase64(certificate);
                builder.Properties[CertificateConfigKey] = encodedCertificate;

                testCluster = builder.Build();
                await testCluster.DeployAsync();

                var client = testCluster.Client;

                var grain    = client.GetGrain <IPingGrain>("pingu");
                var expected = "secret chit chat";
                var actual   = await grain.Echo(expected);

                Assert.Equal(expected, actual);
            }
            finally
            {
                await testCluster?.StopAllSilosAsync();

                testCluster?.Dispose();
            }
        }
示例#2
0
        public void CanCreateCertificates()
        {
            var original = TestCertificateHelper.CreateSelfSignedCertificate(
                CertificateSubjectName,
                new[] { TestCertificateHelper.ClientAuthenticationOid, TestCertificateHelper.ServerAuthenticationOid });
            var encoded = TestCertificateHelper.ConvertToBase64(original);
            var decoded = TestCertificateHelper.ConvertFromBase64(encoded);

            Assert.Equal(original, decoded);
        }
示例#3
0
        public async Task TlsEndToEnd(string[] oids, RemoteCertificateMode certificateMode)
        {
            TestCluster testCluster = default;

            try
            {
                var builder = new TestClusterBuilder()
                              .AddSiloBuilderConfigurator <TlsConfigurator>()
                              .AddClientBuilderConfigurator <TlsConfigurator>();

                var certificate = TestCertificateHelper.CreateSelfSignedCertificate(
                    CertificateSubjectName, oids);

                var encodedCertificate = TestCertificateHelper.ConvertToBase64(certificate);
                builder.Properties[CertificateConfigKey]     = encodedCertificate;
                builder.Properties[ClientCertificateModeKey] = certificateMode.ToString();

                testCluster = builder.Build();
                await testCluster.DeployAsync();

                var client = testCluster.Client;

                var grain    = client.GetGrain <IPingGrain>("pingu");
                var expected = "secret chit chat";
                var actual   = await grain.Echo(expected);

                Assert.Equal(expected, actual);
            }
            finally
            {
                if (testCluster != null)
                {
                    await testCluster.StopAllSilosAsync();

                    testCluster.Dispose();
                }
            }
        }