public void ExecuteSql_LoginError()
        {
            string userId           = "U" + Guid.NewGuid().ToString().Replace("-", "");
            string password         = "******" + Guid.NewGuid().ToString().Replace("-", "");
            string dataSource       = "localhost:1521/xe";
            string connectionString = @"User Id=" + userId + ";Password="******";Data Source=" + dataSource + ";";

            OracleSqlExecuter sqlExecuter = new OracleSqlExecuter(connectionString, new ConsoleLogProvider(), new NullUserInfo());
            var ex = TestUtility.ShouldFail(() => sqlExecuter.ExecuteSql(new[] { "SELECT 123 FROM DUAL" }), userId, dataSource);

            Assert.IsFalse(ex.ToString().Contains(password));
        }
        public void ExecuteSql_SaveLoadTest()
        {
            OracleSqlExecuter sqlExecuter = GetSqlExecuter();
            string            table       = GetRandomTableName();

            sqlExecuter.ExecuteSql(new[]
            {
                "CREATE TABLE " + table + " ( A INTEGER )",
                "INSERT INTO " + table + " VALUES (123)"
            });
            int actual = 0;

            sqlExecuter.ExecuteReader("SELECT * FROM " + table, dr => actual = dr.GetInt32(0));
            Assert.AreEqual(123, actual);
        }
        public void SendUserInfoInSqlContext_WriteWithUser()
        {
            var testUser = new TestUserInfo
            {
                IsUserRecognized = true,
                UserName         = "******",
                Workstation      = "HAL9000"
            };
            var    sqlExecuter = new OracleSqlExecuter(SqlUtility.ConnectionString, new ConsoleLogProvider(), testUser);
            string table       = GetRandomTableName();
            var    result      = new List <string>();

            sqlExecuter.ExecuteSql(new [] { @"CREATE TABLE " + table + " AS SELECT SYS_CONTEXT('USERENV','CLIENT_INFO') ClientInfo FROM DUAL" });

            sqlExecuter.ExecuteReader(@"SELECT * FROM " + table, reader => result.Add(reader[0].ToString()));
            var clientInfo = result.Single();

            TestUtility.AssertContains(clientInfo, testUser.UserName, "CLIENT_INFO should contain username.");
            TestUtility.AssertContains(clientInfo, testUser.Workstation, "CLIENT_INFO should contain client workstation.");
            Assert.AreEqual(SqlUtility.UserContextInfoText(testUser), clientInfo);
        }
Esempio n. 4
0
        public void SendUserInfoInSqlContext_WriteWithUser()
        {
            var testUser = new TestUserInfo
            {
                IsUserRecognized = true,
                UserName = "******",
                Workstation = "HAL9000"
            };
            var sqlExecuter = new OracleSqlExecuter(SqlUtility.ConnectionString, new ConsoleLogProvider(), testUser);
            string table = GetRandomTableName();
            var result = new List<string>();

            sqlExecuter.ExecuteSql(new [] { @"CREATE TABLE " + table + " AS SELECT SYS_CONTEXT('USERENV','CLIENT_INFO') ClientInfo FROM DUAL" });

            sqlExecuter.ExecuteReader(@"SELECT * FROM " + table, reader => result.Add(reader[0].ToString()));
            var clientInfo = result.Single();
            TestUtility.AssertContains(clientInfo, testUser.UserName, "CLIENT_INFO should contain username.");
            TestUtility.AssertContains(clientInfo, testUser.Workstation, "CLIENT_INFO should contain client workstation.");
            Assert.AreEqual(SqlUtility.UserContextInfoText(testUser), clientInfo);
        }
Esempio n. 5
0
        public void ExecuteSql_LoginError()
        {
            string userId = "U" + Guid.NewGuid().ToString().Replace("-", "");
            string password = "******" + Guid.NewGuid().ToString().Replace("-", "");
            string dataSource = "localhost:1521/xe";
            string connectionString = @"User Id=" + userId + ";Password="******";Data Source=" + dataSource + ";";

            OracleSqlExecuter sqlExecuter = new OracleSqlExecuter(connectionString, new ConsoleLogProvider(), new NullUserInfo());
            var ex = TestUtility.ShouldFail(() => sqlExecuter.ExecuteSql(new[] { "SELECT 123 FROM DUAL" }), userId, dataSource);
            Assert.IsFalse(ex.ToString().Contains(password));
        }