Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to ogc-server-statistics to pass all tests #2392

Merged
merged 3 commits into from Jan 22, 2019

Conversation

groldan
Copy link
Member

@groldan groldan commented Jan 19, 2019

This pull request fixes #2076

There were two major errors:

  • RetrieveAllCommand had a hardcoded column name secrole instead of roles, which directly prevented all online tests from running.

  • After fixing that, most tests failed because OGCServiceParser couldn't parse the service name, especially out of the HTTP POST requests log messages. Fixed using regular expressions.

The only test passing was OGCServiceParserTest, but test cases for the failing messages, which were added.

- Move repeated hardcoded values for statistics table
and column names to a constants in a LogColumns utility.

- Use try-with-resources when dealing with JDBC
prepared statements and resultsets.

- Do now swallow exception cause when throwing
DataCommandException
@groldan groldan force-pushed the bug/ogc_statistics_tests branch 2 times, most recently from 5b0f929 to b6cef72 Compare January 19, 2019 15:09
@fvanderbiest fvanderbiest added this to the 18.12 milestone Jan 21, 2019
pStmt.execute("DELETE FROM ogcstatistics.OGC_SERVICES_LOG");

try (Statement pStmt = this.connection.createStatement()){
pStmt.execute(String.format("DELETE FROM %s", QUALIFIED_TABLE_NAME));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware that QUALIFIED_TABLE_NAME is not an user input, but String.format() to format SQL queries is prone to sql injections

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. In this case it's safe as QUALIFIED_TABLE_NAME is a constant to avoid possible typos. It would also make it safe in the event the table name changed (e.g. it has the schema hardcoded, might that change eventually?).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No plan to change this.
Honestly, this looks safe enough for me.

try {
this.connection.setAutoCommit(true);
} catch (SQLException e1) {
e1.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be logged instead of putting it on stdout ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, just amended it.

Most failed because OGCServiceParser couldn't parse the
OGC service name, especially out of the HTTP POST requests
log messages. Fixed using regular expressions.

The only test passing was OGCServiceParserTest, but lacked
test cases for the failing messages, which were added.
@fvanderbiest fvanderbiest merged commit 2ba2d78 into georchestra:master Jan 22, 2019
@groldan groldan mentioned this pull request Jan 25, 2019
@groldan groldan deleted the bug/ogc_statistics_tests branch January 25, 2019 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants