Skip to content

Instantly share code, notes, and snippets.

@up1
Last active August 29, 2015 14:05
Show Gist options
  • Save up1/4fe837903f8deaeff2a5 to your computer and use it in GitHub Desktop.
Save up1/4fe837903f8deaeff2a5 to your computer and use it in GitHub Desktop.
Demo :: TDD with Security
@Test
public void attack_with_sql_injection_to_table_person_should_return_all_data() {
PersonDAO personDAO = new PersonDAO(getDataSource());
List<Person> persons = personDAO.getPerson("'or '1'='1");
assertEquals(5, persons.size());
}
@Test(expected = DataNotFoundException.class)
public void attack_with_sql_injection_to_table_person_should_return_data_not_found() {
PersonDAO personDAO = new PersonDAO(getDataSource());
personDAO.getPerson("'or '1'='1");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment