Search in sources :

Example 1 with ConfigChangedEvent

use of org.nzbhydra.config.ConfigChangedEvent in project nzbhydra2 by theotherp.

the class DontRestrictStatsAuthTest method shouldAllowChangingRestrictionsAtRuntime.

@Test
public void shouldAllowChangingRestrictionsAtRuntime() throws Exception {
    mvc.perform(MockMvcRequestBuilders.get("/config").with(csrf())).andExpect(status().is(401));
    baseConfig.getAuth().setRestrictAdmin(false);
    authenticationFilter.handleConfigChangedEvent(new ConfigChangedEvent(this, new BaseConfig(), baseConfig));
    mvc.perform(MockMvcRequestBuilders.get("/config").with(csrf())).andExpect(status().is(200));
}
Also used : BaseConfig(org.nzbhydra.config.BaseConfig) ConfigChangedEvent(org.nzbhydra.config.ConfigChangedEvent) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with ConfigChangedEvent

use of org.nzbhydra.config.ConfigChangedEvent in project nzbhydra2 by theotherp.

the class HttpBasicAuthTest method shouldAllowChangingUserRolesAtRuntime.

@Test
public void shouldAllowChangingUserRolesAtRuntime() throws Exception {
    checkMainStatsAndConfig("u", "u", 200, 403, 403);
    baseConfig.getAuth().getUsers().get(0).setMaySeeStats(true);
    baseConfig.getAuth().getUsers().get(0).setMaySeeAdmin(true);
    userDetailsManager.handleConfigChangedEvent(new ConfigChangedEvent(this, new BaseConfig(), baseConfig));
    checkMainStatsAndConfig("u", "u", 200, 200, 200);
}
Also used : BaseConfig(org.nzbhydra.config.BaseConfig) ConfigChangedEvent(org.nzbhydra.config.ConfigChangedEvent) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ConfigChangedEvent

use of org.nzbhydra.config.ConfigChangedEvent in project nzbhydra2 by theotherp.

the class HttpBasicAuthTest method setup.

@Before
public void setup() {
    mvc = MockMvcBuilders.webAppContextSetup(context).apply(SecurityMockMvcConfigurers.springSecurity()).build();
    baseConfig.getAuth().getUsers().get(0).setMaySeeStats(false);
    baseConfig.getAuth().getUsers().get(0).setMaySeeAdmin(false);
    userDetailsManager.handleConfigChangedEvent(new ConfigChangedEvent(this, new BaseConfig(), baseConfig));
}
Also used : BaseConfig(org.nzbhydra.config.BaseConfig) ConfigChangedEvent(org.nzbhydra.config.ConfigChangedEvent) Before(org.junit.Before)

Aggregations

BaseConfig (org.nzbhydra.config.BaseConfig)3 ConfigChangedEvent (org.nzbhydra.config.ConfigChangedEvent)3 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Before (org.junit.Before)1