示例#1
0
        public void CON_Connect_AsUser_Failure_NoUserOrPassword()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.RunAs] = ScriptRunnerConnectionHelper.RunAsTypes.User;

            try
            {
                connector.Connect(props);

                Assert.Fail("Should have thrown a InvalidConnectionException");
            }
            catch (InvalidConnectionException ex)
            {
            }

            Assert.IsFalse(connector.IsConnected);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }
示例#2
0
        public void CON_Connect_AsUser_Failure_BadUser()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.RunAs]    = ScriptRunnerConnectionHelper.RunAsTypes.User;
            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Username] = "bad-user";
            var password = Encryptor.Encrypt_AesManaged("bad-password", ScriptRunnerConnector.CryptoKey);

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Password] = password;

            try
            {
                connector.Connect(props);

                Assert.Fail("Should have thrown a InvalidConnectionException");
            }
            catch (InvalidConnectionException ex)
            {
                if (ex.Message != "The user name or password is incorrect" &&
                    ex.Message != "There are currently no logon servers available to service the logon request")
                {
                    Assert.Fail("Threw wrong InvalidConnectionException: " + ex.Message);
                }
            }

            Assert.IsFalse(connector.IsConnected);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }
示例#3
0
        public void CON_Connect_AsUser_Failure_ValidUserNoPassword()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.RunAs]    = ScriptRunnerConnectionHelper.RunAsTypes.User;
            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Username] = "crasher";
            var password = Encryptor.Encrypt_AesManaged("", ScriptRunnerConnector.CryptoKey);

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Password] = password;

            try
            {
                connector.Connect(props);

                Assert.Fail("Should have thrown a InvalidConnectionException");
            }
            catch (InvalidConnectionException ex)
            {
            }

            Assert.IsFalse(connector.IsConnected);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }
示例#4
0
        public void CON_Connect_AsAgent()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            connector.Connect(props);

            Assert.IsTrue(connector.IsConnected);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }
示例#5
0
        public void CON_GetMetadataProvider()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            connector.Connect(props);

            Assert.IsTrue(connector.IsConnected);

            var metadataProvider = connector.GetMetadataProvider();

            Assert.IsNotNull(metadataProvider);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }
示例#6
0
        public void CON_Connect_AsUser_Success()
        {
            IConnector connector = new ScriptRunnerConnector();

            var props = GetTestConnectionDictionary();

            // needs valid creds
            var password = Encryptor.Encrypt_AesManaged("myPasswordHere", ScriptRunnerConnector.CryptoKey);

            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.RunAs]    = ScriptRunnerConnectionHelper.RunAsTypes.User;
            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Username] = "nkeefe";
            props[ScriptRunnerConnectionHelper.ConnectionPropertyKeys.Password] = password;

            connector.Connect(props);

            Assert.IsTrue(connector.IsConnected);

            if (connector.IsConnected)
            {
                connector.Disconnect();
            }
        }