当前位置: 首页>>代码示例>>Java>>正文


Java Settings.appendProperty方法代码示例

本文整理汇总了Java中org.sonar.api.config.Settings.appendProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.appendProperty方法的具体用法?Java Settings.appendProperty怎么用?Java Settings.appendProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.config.Settings的用法示例。


在下文中一共展示了Settings.appendProperty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRealmMissingHeader

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests when the header is missing.
 */
@Test
public void testRealmMissingHeader() {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.getName();
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(null);
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");

    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);
    when(context.getResponse()).thenReturn(mock(HttpServletResponse.class));
    provider.init(context);
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:28,代码来源:RealmTest.java

示例2: testRealmMissingHeaderValue

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests when the header has empty header value.
 */
@Test
public void testRealmMissingHeaderValue() {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn("");
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");

    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);
    when(context.getResponse()).thenReturn(mock(HttpServletResponse.class));
    provider.init(context);
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:27,代码来源:RealmTest.java

示例3: testRealmOnLocalhost

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests the typical authentication process when the server request is
 * against localhost.
 */
@Test
public void testRealmOnLocalhost() {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getServerName()).thenReturn("localhost");

    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);
    when(context.getResponse()).thenReturn(mock(HttpServletResponse.class));
    provider.init(context);
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:26,代码来源:RealmTest.java

示例4: testStaticValues

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testStaticValues() {

    final Settings settings = new Settings();
    settings.appendProperty(ReverseProxyAuthSettings.ALLOW_NEW_USERS, "true");
    settings.appendProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, ReverseProxyAuthPlugin.KEY);
    settings.appendProperty(CoreProperties.SERVER_BASE_URL, "http://foo.com/sonar");
    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(new ReverseProxyAuthSettings(settings));
    assertEquals(ReverseProxyAuthPlugin.KEY, provider.getKey());
    assertNotNull(provider.getName());
    final Display display = provider.getDisplay();
    assertNotNull(display);
    assertEquals("http://foo.com/sonar/static/reverseproxyauth/proxy.png", display.getIconPath());
    assertTrue(provider.isEnabled());
    assertTrue(provider.allowsUsersToSignUp());
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:17,代码来源:RealmTest.java

示例5: testUserProvider

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testUserProvider() {

    final Settings settings = new Settings();
    settings.appendProperty(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY, "true");
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        "[email protected]");
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");
    when(httpServletRequest.getRequestURL())
        .thenReturn(new StringBuffer("/"));
    when(httpServletRequest.getContextPath())
        .thenReturn("/");

    final ReverseProxyAuthRealm realm = new ReverseProxyAuthRealm(new ReverseProxyAuthSettings(settings));
    realm.init();
    final ExternalUsersProvider.Context context = new ExternalUsersProvider.Context(null, httpServletRequest);
    realm.getUsersProvider().doGetUserDetails(context);
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:25,代码来源:RealmTest.java

示例6: testUserProviderLocalhost

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testUserProviderLocalhost() {

    final Settings settings = new Settings();
    settings.appendProperty(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY, "true");
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        "blah");
    when(httpServletRequest.getServerName())
        .thenReturn("localhost");
    when(httpServletRequest.getRequestURL())
        .thenReturn(new StringBuffer("/"));
    when(httpServletRequest.getContextPath())
        .thenReturn("/");

    final ReverseProxyAuthRealm realm = new ReverseProxyAuthRealm(new ReverseProxyAuthSettings(settings));
    realm.init();
    final ExternalUsersProvider.Context context = new ExternalUsersProvider.Context(null, httpServletRequest);
    assertEquals("", realm.getUsersProvider().doGetUserDetails(context).getEmail());
    assertEquals("", realm.getUsersProvider().doGetUserDetails(context).getName());
    assertEquals("", realm.getUsersProvider().doGetUserDetails(context).getUserId());
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:27,代码来源:RealmTest.java

示例7: testUserProviderMissingHeader

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
@Test
public void testUserProviderMissingHeader() {

    final Settings settings = new Settings();
    settings.appendProperty(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY, "true");
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        null);
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");
    when(httpServletRequest.getRequestURL())
        .thenReturn(new StringBuffer("/"));
    when(httpServletRequest.getContextPath())
        .thenReturn("/");

    final ReverseProxyAuthRealm realm = new ReverseProxyAuthRealm(new ReverseProxyAuthSettings(settings));
    realm.init();
    final ExternalUsersProvider.Context context = new ExternalUsersProvider.Context(null, httpServletRequest);
    assertNull(realm.getUsersProvider().doGetUserDetails(context));
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:25,代码来源:RealmTest.java

示例8: testMissingLocalhostParameter

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests when the header is missing.
 */
@Test
public void testMissingLocalhostParameter() {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    assertFalse(reverseProxyAuthSettings.isLocalHost(mock(ServletRequest.class)));
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:14,代码来源:RealmTest.java

示例9: testRealm

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests the typical authentication process.
 *
 * @throws IOException
 */
@Test
public void testRealm() throws IOException {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");
    settings.appendProperty(CoreProperties.SERVER_BASE_URL, "http://foo.com");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.getName();
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        "[email protected]");
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");
    when(httpServletRequest.getRequestURL())
        .thenReturn(new StringBuffer("/"));
    when(httpServletRequest.getContextPath())
        .thenReturn("/");

    final Server mockServer = mock(Server.class);
    when(mockServer.getContextPath()).thenReturn("");
    when(mockServer.getURL()).thenReturn("http://foo.com");
    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);
    when(context.getServerBaseURL()).thenReturn("http://foo.com");
    final HttpServletResponse response = mock(HttpServletResponse.class);
    when(context.getResponse()).thenReturn(response);
    provider.init(context);
    verify(context).authenticate(Matchers.any());
    verify(response).sendRedirect("http://foo.com/reverseproxyauth/redirect_back_or_home_url");
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:43,代码来源:RealmTest.java

示例10: testRealmDifferentContext

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests the typical authentication process.
 *
 * @throws IOException
 */
@Test
public void testRealmDifferentContext() throws IOException {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");
    settings.appendProperty(CoreProperties.SERVER_BASE_URL, "http://foo.com/barbar");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.getName();
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        "[email protected]");
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");

    final Server mockServer = mock(Server.class);
    when(mockServer.getContextPath()).thenReturn("/barbar");
    when(mockServer.getURL()).thenReturn("http://foo.com/barbar");
    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);
    final HttpServletResponse response = mock(HttpServletResponse.class);
    when(context.getResponse()).thenReturn(response);
    when(context.getServerBaseURL()).thenReturn("http://foo.com/barbar");
    provider.init(context);
    verify(context).authenticate(Matchers.any());
    verify(response).sendRedirect("http://foo.com/barbar/reverseproxyauth/redirect_back_or_home_url");
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:39,代码来源:RealmTest.java

示例11: testTerminatedResponse

import org.sonar.api.config.Settings; //导入方法依赖的package包/类
/**
 * Tests terminated response. IOException on sendRedirect().
 *
 * @throws IOException
 */
@Test
public void testTerminatedResponse() throws IOException {

    final Settings settings = new Settings();
    settings.appendProperty("reverseproxyauth.header.name",
        "X-Forwarded-User");
    settings.appendProperty("reverseproxyauth.localhost", "localhost");

    final ReverseProxyAuthSettings reverseProxyAuthSettings = new ReverseProxyAuthSettings(settings);
    final SecurityRealm realm = new ReverseProxyAuthRealm(reverseProxyAuthSettings);
    realm.getName();
    realm.init();

    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(httpServletRequest.getHeader("X-Forwarded-User")).thenReturn(
        "[email protected]");
    when(httpServletRequest.getServerName())
        .thenReturn("not.localhost.com");
    when(httpServletRequest.getRequestURL())
        .thenReturn(new StringBuffer("/"));
    when(httpServletRequest.getContextPath())
        .thenReturn("/");

    final ReverseProxyAuthUsersIdentityProvider provider = new ReverseProxyAuthUsersIdentityProvider(reverseProxyAuthSettings);
    final Context context = mock(Context.class);
    when(context.getRequest()).thenReturn(httpServletRequest);

    final HttpServletResponse response = mock(HttpServletResponse.class);
    final IOException ioException = new IOException();
    doThrow(ioException).when(response).sendRedirect(Matchers.anyString());
    when(context.getResponse()).thenReturn(response);

    try {
        provider.init(context);
    } catch (final RuntimeException e) {
        assertEquals(ioException, e.getCause());
    }
    verify(context).authenticate(any());
}
 
开发者ID:trajano,项目名称:reverse-proxy-auth-sonar-plugin,代码行数:45,代码来源:RealmTest.java


注:本文中的org.sonar.api.config.Settings.appendProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。