Search in sources :

Example 6 with Table

use of com.jsql.model.bean.database.Table in project jsql-injection by ron190.

the class AbstractTestSuite method listColumns.

@Test
public void listColumns() throws JSqlException {
    Set<Object> set1 = new HashSet<>();
    Set<Object> set2 = new HashSet<>();
    try {
        List<Column> cs = DataAccess.listColumns(new Table(this.jsqlTableName, "0", new Database(this.jsqlDatabaseName, "0")));
        List<String> columnsFound = new ArrayList<>();
        for (Column c : cs) {
            columnsFound.add(c.toString());
        }
        set1.addAll(columnsFound);
        set2.addAll(this.columnToFind);
        LOGGER.info("listColumns: found " + set1 + "\nto find " + set2 + "\n");
        Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
    } catch (AssertionError e) {
        Set<Object> tmp = new TreeSet<>();
        for (Object x : set1) {
            if (!set2.contains(x)) {
                tmp.add(x);
            }
        }
        for (Object x : set2) {
            if (!set1.contains(x)) {
                tmp.add(x);
            }
        }
        throw new AssertionError("Error listColumns: " + tmp + "\n" + e);
    }
}
Also used : Table(com.jsql.model.bean.database.Table) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) Column(com.jsql.model.bean.database.Column) Database(com.jsql.model.bean.database.Database) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with Table

use of com.jsql.model.bean.database.Table in project jsql-injection by ron190.

the class AbstractTestSuite method listValues.

@Test
public void listValues() throws JSqlException {
    Set<Object> set1 = new TreeSet<>();
    Set<Object> set2 = new TreeSet<>();
    try {
        String[][] vs = DataAccess.listValues(Arrays.asList(new Column(this.jsqlColumnName, new Table(this.jsqlTableName, "0", new Database(this.jsqlDatabaseName, "0")))));
        List<String> valuesFound = new ArrayList<>();
        for (String[] v : vs) {
            valuesFound.add(v[2].replaceAll("\r\n", "\n"));
        }
        set1.addAll(valuesFound);
        set2.addAll(this.valueToFind);
        LOGGER.info("<<listValues: found " + set1.toString().replaceAll("\n", "[n]").replaceAll("\r", "[r]") + "\nto find " + set2.toString().replaceAll("\n", "[n]").replaceAll("\r", "[r]") + ">>\n");
        Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
    } catch (AssertionError e) {
        Set<Object> tmp = new TreeSet<>();
        for (Object x : set1) {
            if (!set2.contains(x)) {
                tmp.add(x);
            }
        }
        for (Object x : set2) {
            if (!set1.contains(x)) {
                tmp.add(x);
            }
        }
        throw new AssertionError("Error listValues: " + tmp + "\n" + e);
    }
}
Also used : Table(com.jsql.model.bean.database.Table) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) Column(com.jsql.model.bean.database.Column) TreeSet(java.util.TreeSet) Database(com.jsql.model.bean.database.Database) Test(org.junit.Test)

Example 8 with Table

use of com.jsql.model.bean.database.Table in project jsql-injection by ron190.

the class AbstractTestSuite method listTables.

@Test
public void listTables() throws JSqlException {
    Set<Object> set1 = new HashSet<>();
    Set<Object> set2 = new HashSet<>();
    try {
        List<Table> ts = DataAccess.listTables(new Database(this.jsqlDatabaseName, "0"));
        List<String> tablesFound = new ArrayList<>();
        for (Table t : ts) {
            tablesFound.add(t.toString());
        }
        set1.addAll(tablesFound);
        set2.addAll(this.tableToFind);
        LOGGER.info("listTables: found " + set1 + "\nto find " + set2 + "\n");
        Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
    } catch (AssertionError e) {
        Set<Object> tmp = new TreeSet<>();
        for (Object x : set1) {
            if (!set2.contains(x)) {
                tmp.add(x);
            }
        }
        for (Object x : set2) {
            if (!set1.contains(x)) {
                tmp.add(x);
            }
        }
        throw new AssertionError("Error listTables: " + tmp + "\n" + e);
    }
}
Also used : Table(com.jsql.model.bean.database.Table) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) Database(com.jsql.model.bean.database.Database) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Table (com.jsql.model.bean.database.Table)8 ArrayList (java.util.ArrayList)5 Database (com.jsql.model.bean.database.Database)4 Request (com.jsql.model.bean.util.Request)3 InjectionFailureException (com.jsql.model.exception.InjectionFailureException)3 SlidingException (com.jsql.model.exception.SlidingException)3 ResultSet (java.sql.ResultSet)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 TreeSet (java.util.TreeSet)3 Matcher (java.util.regex.Matcher)3 Test (org.junit.Test)3 AbstractElementDatabase (com.jsql.model.bean.database.AbstractElementDatabase)2 Column (com.jsql.model.bean.database.Column)2 IgnoreMessageException (com.jsql.model.exception.IgnoreMessageException)2 JSqlException (com.jsql.model.exception.JSqlException)2 SuspendableGetRows (com.jsql.model.suspendable.SuspendableGetRows)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 LoopDetectedSlidingException (com.jsql.model.exception.LoopDetectedSlidingException)1 StoppedByUserSlidingException (com.jsql.model.exception.StoppedByUserSlidingException)1