.url(url));
}
- public static Response call(Request.Builder requestBuilder) {
+ private static Response call(Request.Builder requestBuilder) {
try {
requestBuilder.header("Authorization", Credentials.basic("admin", "admin"));
Response response = new OkHttpClient.Builder()
/**
* This servlet filter sets response headers that enable browser protection against several classes if Web attacks.
- * The list of headers is mirrored in environment.rb as a workaround to Rack swallowing the headers..
*/
public class SecurityServletFilter implements Filter {
assertGlobalSetting("my.key", "My Value");
}
+ @Test
+ public void persist_global_setting_with_non_ascii_characters() {
+ callForGlobalSetting("my.key", "fi±∞…");
+
+ assertGlobalSetting("my.key", "fi±∞…");
+ assertThat(settingsChangeNotifier.wasCalled).isTrue();
+ }
+
@Test
public void fail_when_no_key() {
expectedException.expect(IllegalArgumentException.class);
"sonar.plugin.licenseHash.secured");
}
+ @Test
+ public void return_simple_value_with_non_ascii_characters() throws Exception {
+ setAuthenticatedUser();
+ definitions.addComponent(PropertyDefinition
+ .builder("foo")
+ .build());
+ propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("fi±∞…"));
+
+ ValuesWsResponse result = executeRequestForGlobalProperties("foo");
+
+ assertThat(result.getSettings(0).getValue()).isEqualTo("fi±∞…");
+ }
+
@Test
public void fail_when_user_has_not_project_browse_permission() throws Exception {
userSession.login("project-admin").addProjectUuidPermissions(CODEVIEWER, project.uuid());
<filter-name>UserSessionFilter</filter-name>
<filter-class>org.sonar.server.user.UserSessionFilter</filter-class>
</filter>
+ <filter>
+ <filter-name>SetCharacterEncodingFilter</filter-name>
+ <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
+ <init-param>
+ <param-name>encoding</param-name>
+ <param-value>UTF-8</param-value>
+ </init-param>
+ </filter>
<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>org.sonar.server.platform.web.SecurityServletFilter</filter-class>
</filter>
<!-- order of execution is important -->
+ <filter-mapping>
+ <filter-name>SetCharacterEncodingFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
<filter-mapping>
<filter-name>RootFilter</filter-name>
<url-pattern>/*</url-pattern>