Skip to content

Instantly share code, notes, and snippets.

@beyondxscratch
beyondxscratch / install-dependency-track.sh
Last active Oct 8, 2018
Install Dependency-Track as a Docker Container
View install-dependency-track.sh
docker pull owasp/dependency-track
docker volume create --name dependency-track
docker run -d -p 8080:8080 –name dependency-track -v dependency-track:/data owasp/dependency-track
View retrieves-next-showings.feature
Feature: As a cinephile In order to not loose a single minute of a movie I want to know what are the next showings of the movie theater
Background:
Given a cinephile
Scenario: Looking for the next showings before the start of the last one
Given the last showing is not started yet
When the user asks for the next showings
Then the returned showings are not started yet
And the returned showings are not starting in the next 15 minutes
View RetrieveShowingsStepDefs.java
public class StepDefs implements En {
public StepDefs() {
Given("^a cinephile$", () -> me = new Cinephile("me"));
Given("^the last showing is not started yet$",
() -> lastShowing = new Showing(now().plusHours(3)));
When("^the user asks for the next showings$",
() -> nextShowings = searchShowings.searchNextShowingsFor(me));
View table-bad-pattern.feature
Given the showing:
| name | schedule | director | rating | duration |
| Gore Movie | 21H00 | Jhon Doe | NC-17 | PT2H5M |
When a child tries to buy a ticket for this showing
Then the purchase is forbidden
View ForbiddenPurchase.feature
Given a NC-17 rated showing
When a child tries to buy a ticket for this showing
Then the purchase is forbidden
View karate-profile.feature
Feature: Profile endpoint
Scenario: creating a profile
Given path 'profiles'
And request
"""
{ "topics": [{"name": "DDD"},{"name": "Hexagonal Architecture"}],"talksFormats": ["QUICKIE","CONFERENCE"] }
"""
When method post
Then assert responseStatus == 201
View RawSQLAuthenticationProvider.java
jdbcTemplate
.queryForObject(
"Select * from users where username='" + name + "' and password='" + password + "'",
BeanPropertyRowMapper.newInstance(DBUser.class));
View sqlInjection.sql
Select * from users where username='' OR '1'='1' LIMIT 1 --' and password=''
@beyondxscratch
beyondxscratch / BoilerplateConfiguration.java
Last active Jul 27, 2019
Example of a boilerplate bean factory
View BoilerplateConfiguration.java
@Configuration
public class DomainConfiguration {
@Bean
public RetrieveSanitaryGrades retrieveSanitaryGrades() {
return new RetrieveSanitaryGrades();
}
@Bean
public SearchRestaurants restaurantsFinder(Restaurants restaurants,
View domainannotations.kt
import java.lang.annotation.Inherited
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS)
@Inherited
annotation class DomainService
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS)
@Inherited