-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend/frontend] Improve UI of score settings/validation (#1198)
- Loading branch information
Showing
13 changed files
with
736 additions
and
515 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
openbas-api/src/main/java/io/openbas/migration/V3_36__Alter_inject_expectation_score.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_36__Alter_inject_expectation_score extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Connection connection = context.getConnection(); | ||
Statement select = connection.createStatement(); | ||
select.execute( | ||
"ALTER TABLE injects_expectations ALTER COLUMN inject_expectation_expected_score SET NOT NULL,\n" | ||
+ "ALTER COLUMN inject_expectation_expected_score SET DEFAULT 100;"); | ||
} | ||
} |
640 changes: 315 additions & 325 deletions
640
openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
openbas-api/src/test/java/io/openbas/utils/fixtures/InjectExpectationFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.openbas.utils.fixtures; | ||
|
||
import io.openbas.database.model.Exercise; | ||
import io.openbas.database.model.Inject; | ||
import io.openbas.database.model.InjectExpectation; | ||
import io.openbas.database.model.Team; | ||
|
||
public class InjectExpectationFixture { | ||
|
||
public static InjectExpectation createPreventionInjectExpectation(Team team, Inject inject) { | ||
InjectExpectation injectExpectation = new InjectExpectation(); | ||
injectExpectation.setInject(inject); | ||
injectExpectation.setType(InjectExpectation.EXPECTATION_TYPE.PREVENTION); | ||
injectExpectation.setTeam(team); | ||
injectExpectation.setExpectedScore(100.0); | ||
return injectExpectation; | ||
} | ||
|
||
public static InjectExpectation createDetectionInjectExpectation(Team team, Inject inject) { | ||
InjectExpectation injectExpectation = new InjectExpectation(); | ||
injectExpectation.setInject(inject); | ||
injectExpectation.setType(InjectExpectation.EXPECTATION_TYPE.DETECTION); | ||
injectExpectation.setTeam(team); | ||
injectExpectation.setExpectedScore(100.0); | ||
return injectExpectation; | ||
} | ||
|
||
public static InjectExpectation createManualInjectExpectation(Team team, Inject inject) { | ||
InjectExpectation injectExpectation = new InjectExpectation(); | ||
injectExpectation.setInject(inject); | ||
injectExpectation.setType(InjectExpectation.EXPECTATION_TYPE.MANUAL); | ||
injectExpectation.setTeam(team); | ||
injectExpectation.setExpectedScore(100.0); | ||
return injectExpectation; | ||
} | ||
|
||
public static InjectExpectation createArticleInjectExpectation(Team team, Inject inject) { | ||
InjectExpectation injectExpectation = new InjectExpectation(); | ||
injectExpectation.setInject(inject); | ||
injectExpectation.setType(InjectExpectation.EXPECTATION_TYPE.ARTICLE); | ||
injectExpectation.setTeam(team); | ||
injectExpectation.setExpectedScore(100.0); | ||
return injectExpectation; | ||
} | ||
|
||
public static InjectExpectation createManualInjectExpectationWithExercise(Team team, Inject inject, | ||
Exercise exercise, String expectationName) { | ||
InjectExpectation injectExpectation = new InjectExpectation(); | ||
injectExpectation.setInject(inject); | ||
injectExpectation.setType(InjectExpectation.EXPECTATION_TYPE.MANUAL); | ||
injectExpectation.setTeam(team); | ||
injectExpectation.setExpectedScore(100.0); | ||
injectExpectation.setExercise(exercise); | ||
injectExpectation.setName(expectationName); | ||
return injectExpectation; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.