Beispiel #1
0
        public async Task UserVerification_SiloDown_UserRegisteredWhenRestarted()
        {
            /*
             * Enable Verification service
             * Disable verification service
             * Send Registration
             * Assert that the state is pending
             * Switch on verification service
             * Assert that the state is verified
             */

            // Arrange
            await _registrationCluster.WaitForLivenessToStabilizeAsync();

            await _registrationStatusCluster.WaitForLivenessToStabilizeAsync();

            _verificationCluster = _testHelper.GenerateTestCluster <UserVerificationGrain>();
            await _verificationCluster.WaitForLivenessToStabilizeAsync();

            var userRegistrationGrain =
                _registrationCluster.Client.GetGrain <IUserRegistrationGrain>(_faker.Internet.Email());
            var userRegistrationKey =
                await userRegistrationGrain.RegisterAsync(_faker.Random.String2(5), _faker.Random.String2(5));

            await AssertRegistrationState(userRegistrationKey, UserRegistrationStatusEnum.Verified);

            await _verificationCluster.StopSiloAsync(_verificationCluster.Primary);

            var userRegistrationGrain1 =
                _registrationCluster.Client.GetGrain <IUserRegistrationGrain>(_faker.Internet.Email());
            var userRegistrationKey1 =
                await userRegistrationGrain1.RegisterAsync(_faker.Random.String2(5), _faker.Random.String2(5));

            await AssertRegistrationState(userRegistrationKey1, UserRegistrationStatusEnum.Pending);

            // Act
            // Build Verification Service
            await _verificationCluster.StartAdditionalSiloAsync();

            await _verificationCluster.WaitForLivenessToStabilizeAsync();

            // Assert
            await AssertRegistrationState(userRegistrationKey1, UserRegistrationStatusEnum.Verified);

            await _registrationCluster.StopAllSilosAsync();

            await _registrationStatusCluster.StopAllSilosAsync();

            await _verificationCluster.StopAllSilosAsync();
        }
Beispiel #2
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();
            }
        }
 public async Task DisposeAsync()
 {
     if (this.cluster == null)
     {
         return;
     }
     await cluster.StopAllSilosAsync();
 }
        public async Task DisposeAsync()
        {
            if (testCluster is null)
            {
                return;
            }

            try
            {
                await testCluster.StopAllSilosAsync();
            }
            finally
            {
                await testCluster.DisposeAsync();

                testCluster = null;
            }
        }
Beispiel #5
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();
                }
            }
        }