forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
webgoat-lessons/missing-function-ac/src/main/resources/i18n/WebGoatLabels.properties
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
53 changes: 53 additions & 0 deletions
53
...ssing-function-ac/src/test/org/owasp/webgoat/plugin/MissingFunctionACHiddenMenusTest.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,53 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.owasp.webgoat.assignments.AssignmentEndpointTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
|
||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class MissingFunctionACHiddenMenusTest extends AssignmentEndpointTest { | ||
|
||
private MockMvc mockMvc; | ||
|
||
@Before | ||
public void setup() { | ||
MissingFunctionACHiddenMenus hiddenMenus = new MissingFunctionACHiddenMenus(); | ||
init(hiddenMenus); | ||
this.mockMvc = standaloneSetup(hiddenMenus).build(); | ||
} | ||
|
||
@Test | ||
public void HiddenMenusSuccess() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/access-control/hidden-menu") | ||
.param("hiddenMenu1", "Users") | ||
.param("hiddenMenu2", "Config")) | ||
.andExpect(jsonPath("$.feedback", CoreMatchers.is(messages.getMessage("access-control.hidden-menus.success")))) | ||
.andExpect(jsonPath("$.lessonCompleted", CoreMatchers.is(true))); | ||
} | ||
|
||
@Test | ||
public void HiddenMenusClose() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/access-control/hidden-menu") | ||
.param("hiddenMenu1", "Config") | ||
.param("hiddenMenu2", "Users")) | ||
.andExpect(jsonPath("$.feedback", CoreMatchers.is(messages.getMessage("access-control.hidden-menus.close")))) | ||
.andExpect(jsonPath("$.lessonCompleted", CoreMatchers.is(false))); | ||
} | ||
|
||
@Test | ||
public void HiddenMenusFailure() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/access-control/hidden-menu") | ||
.param("hiddenMenu1", "Foo") | ||
.param("hiddenMenu2", "Bar")) | ||
.andExpect(jsonPath("$.feedback", CoreMatchers.is(messages.getMessage("access-control.hidden-menus.failure")))) | ||
.andExpect(jsonPath("$.lessonCompleted", CoreMatchers.is(false))); | ||
} | ||
} |