]> source.dussan.org Git - sonarqube.git/blob
4f342cfe5a8e3b40193a8cf5f32e1d1e070e49eb
[sonarqube.git] /
1 /*
2  * SonarQube, open source software quality management tool.
3  * Copyright (C) 2008-2014 SonarSource
4  * mailto:contact AT sonarsource DOT com
5  *
6  * SonarQube is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * SonarQube is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 package org.sonar.server.db.migrations.v451;
21
22 import org.junit.ClassRule;
23 import org.junit.Test;
24 import org.sonar.core.persistence.TestDatabase;
25 import org.sonar.server.db.migrations.DatabaseMigration;
26
27 import static org.fest.assertions.Assertions.assertThat;
28
29 public class DeleteUnescapedActivitiesTest {
30
31   @ClassRule
32   public static TestDatabase db = new TestDatabase().schema(DeleteUnescapedActivitiesTest.class, "schema.sql");
33
34   DatabaseMigration migration;
35
36   @Test
37   public void execute() throws Exception {
38     migration = new DeleteUnescapedActivities(db.database());
39     db.prepareDbUnit(getClass(), "execute.xml");
40     migration.execute();
41     db.assertDbUnit(getClass(), "execute-result.xml", "activities");
42   }
43
44   @Test
45   public void is_unescaped() throws Exception {
46     assertThat(DeleteUnescapedActivities.isUnescaped(
47       "ruleKey=findbugs:PT_RELATIVE_PATH_TRAVERSAL;profileKey=java-findbugs-74105;severity=MAJOR;" +
48         "key=java-findbugs-74105:findbugs:PT_RELATIVE_PATH_TRAVERSAL"))
49       .isFalse();
50     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar")).isFalse();
51     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar;foo;ruleKey=S001")).isTrue();
52     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo=foo;ruleKey=S001")).isTrue();
53
54   }
55 }