Ejemplo n.º 1
0
        public void RedisSources_Test_With_InValidArgs_Expected_Valid_InValidationResult()
        {
            var handler = new RedisSources();
            var result  = handler.Test("asd");

            Assert.IsFalse(result.IsValid);
        }
Ejemplo n.º 2
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test Redis Source", GlobalConstants.WarewolfInfo);
                msg.HasError = false;
                values.TryGetValue(Warewolf.Service.TestRedisSource.RedisSource, out StringBuilder resourceDefinition);

                var redisServiceSourceDefinition = serializer.Deserialize <RedisSourceDefinition>(resourceDefinition);
                var con    = new RedisSources();
                var result = con.Test(new RedisSource
                {
                    HostName           = redisServiceSourceDefinition.HostName,
                    Port               = redisServiceSourceDefinition.Port,
                    AuthenticationType = redisServiceSourceDefinition.AuthenticationType,
                    Password           = redisServiceSourceDefinition.Password
                });
                msg.HasError = false;
                msg.Message  = new StringBuilder(result.IsValid ? serializer.Serialize(result.Result) : result.ErrorMessage);
                msg.HasError = !result.IsValid;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 3
0
        public void RedisSources_Test_With_InvalidHost__AuthenticationType_Anonymous_Expected_InvalidValidationResult()
        {
            var source = new RedisSource
            {
                HostName           = "ddd:222",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Anonymous,
                Port = "6379"
            }.ToString();

            try
            {
                var handler = new RedisSources();
                var result  = handler.Test(source);
                Assert.IsFalse(result.IsValid);
                Assert.AreEqual("could not connect to redis Instance at ddd:222:6379\r\nNo such host is known", result.ErrorMessage);
            }
            catch (Exception e)
            {
                if (e.Message.Contains("could not connect to redis Instance"))
                {
                    Assert.Inconclusive(e.Message);
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 4
0
        public void RedisSources_Test_With_ValidHost_AuthenticationType_Anonymous_Expected_ValidValidationResult()
        {
            try
            {
                var dependency = new Depends(Depends.ContainerType.AnonymousRedis);
                var source     = new RedisSource
                {
                    HostName           = dependency.Container.IP,
                    AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Anonymous,
                    Port = dependency.Container.Port
                }.ToString();

                var handler = new RedisSources();
                var result  = handler.Test(source);
                Assert.IsTrue(result.IsValid, result.ErrorMessage);
            }
            catch (Exception e)
            {
                if (e.Message.Contains("could not connect to redis Instance"))
                {
                    Assert.Inconclusive(e.Message);
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 5
0
        public void RedisSources_Test_With_ValidHost_AuthenticationType_Anonymous_Expected_ValidValidationResult()
        {
            var source = new RedisSource
            {
                HostName           = Depends.EnableDocker?Depends.RigOpsIP:Depends.SVRDEVIP,
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Anonymous,
                Port = "6380"
            }.ToString();

            var handler = new RedisSources();
            var result  = handler.Test(source);

            Assert.IsTrue(result.IsValid, result.ErrorMessage);
        }
Ejemplo n.º 6
0
        public void RedisSources_Test_With_InvalidHost_AuthenticationType_Password_Expected_InvalidValidationResult()
        {
            var source = new RedisSource
            {
                HostName           = "ddd",
                Port               = "6380",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Password,
                Password           = "******"
            }.ToString();

            var handler = new RedisSources();
            var result  = handler.Test(source);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("could not connect to redis Instance at ddd:6380\r\nNo such host is known", result.ErrorMessage);
        }
Ejemplo n.º 7
0
        public void RedisSources_Test_With_ValidHost_AuthenticationType_Password_Expected_ValidValidationResult()
        {
            CustomContainer.Register(new Mock <IWarewolfPerformanceCounterLocater>().Object);
            CustomContainer.Register(new Mock <IResourceCatalog>().Object);
            var dependency = new Depends(Depends.ContainerType.Redis);
            var source     = new RedisSource
            {
                HostName           = dependency.Container.IP,
                Port               = dependency.Container.Port,
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Password,
                Password           = "******"
            }.ToString();

            try
            {
                var handler = new RedisSources();
                var result  = handler.Test(source);
                Assert.IsTrue(result.IsValid, result.ErrorMessage);
            }
            catch (Exception e)
            {
                Assert.IsFalse(e.Message.Contains("could not connect to redis Instance"), e.Message);
            }
        }