forked from p15670423/monkey
UI: Use new "unset" island mode
This commit is contained in:
parent
2b60b4ed81
commit
301f2fc89c
|
@ -93,7 +93,7 @@ class AppComponent extends AuthComponent {
|
|||
if (res) {
|
||||
this.setMode()
|
||||
.then(() => {
|
||||
if (this.state.islandMode === null) {
|
||||
if (this.state.islandMode === "unset") {
|
||||
return
|
||||
}
|
||||
this.authFetch('/api')
|
||||
|
@ -151,12 +151,12 @@ class AppComponent extends AuthComponent {
|
|||
};
|
||||
|
||||
needsRedirectionToLandingPage = (route_path) => {
|
||||
return (this.state.islandMode === null && route_path !== Routes.LandingPage)
|
||||
return (this.state.islandMode === "unset" && route_path !== Routes.LandingPage)
|
||||
}
|
||||
|
||||
needsRedirectionToGettingStarted = (route_path) => {
|
||||
return route_path === Routes.LandingPage &&
|
||||
this.state.islandMode !== null && this.state.islandMode !== undefined
|
||||
this.state.islandMode !== "unset" && this.state.islandMode !== undefined
|
||||
}
|
||||
|
||||
redirectTo = (userPath, targetPath) => {
|
||||
|
|
|
@ -58,7 +58,7 @@ class ConfigurePageComponent extends AuthComponent {
|
|||
}
|
||||
|
||||
getSectionsOrder() {
|
||||
let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced'
|
||||
let islandMode = this.props.islandMode !== 'unset' ? this.props.islandMode : 'advanced'
|
||||
return CONFIGURATION_TABS_PER_MODE[islandMode];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import pytest
|
|||
from tests.utils import raise_
|
||||
|
||||
from monkey_island.cc.models.island_mode_model import IslandMode
|
||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||
from monkey_island.cc.resources import island_mode as island_mode_resource
|
||||
from monkey_island.cc.resources.island_mode import IslandMode as IslandModeResource
|
||||
|
||||
|
@ -13,7 +14,7 @@ def uses_database():
|
|||
IslandMode.objects().delete()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ["ransomware", "advanced"])
|
||||
@pytest.mark.parametrize("mode", [IslandModeEnum.RANSOMWARE.value, IslandModeEnum.ADVANCED.value, IslandModeEnum.UNSET.value])
|
||||
def test_island_mode_post(flask_client, mode, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"monkey_island.cc.resources.island_mode.update_config_on_mode_set",
|
||||
|
@ -42,12 +43,12 @@ def test_island_mode_post__internal_server_error(monkeypatch, flask_client):
|
|||
monkeypatch.setattr(island_mode_resource, "set_mode", lambda x: raise_(Exception()))
|
||||
|
||||
resp = flask_client.post(
|
||||
IslandModeResource.urls[0], data=json.dumps({"mode": "ransomware"}), follow_redirects=True
|
||||
IslandModeResource.urls[0], data=json.dumps({"mode":IslandModeEnum.RANSOMWARE.value}), follow_redirects=True
|
||||
)
|
||||
assert resp.status_code == 500
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ["ransomware", "advanced"])
|
||||
@pytest.mark.parametrize("mode", [IslandModeEnum.RANSOMWARE.value, IslandModeEnum.ADVANCED.value])
|
||||
def test_island_mode_endpoint(flask_client, uses_database, mode):
|
||||
flask_client.post(
|
||||
IslandModeResource.urls[0], data=json.dumps({"mode": mode}), follow_redirects=True
|
||||
|
@ -63,4 +64,4 @@ def test_island_mode_endpoint__invalid_mode(flask_client, uses_database):
|
|||
)
|
||||
resp_get = flask_client.get(IslandModeResource.urls[0], follow_redirects=True)
|
||||
assert resp_post.status_code == 422
|
||||
assert json.loads(resp_get.data)["mode"] is None
|
||||
assert json.loads(resp_get.data)["mode"] == IslandModeEnum.UNSET.value
|
||||
|
|
Loading…
Reference in New Issue