~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNReposTests.java

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import org.apache.subversion.javahl.types.*;
27
27
 
28
28
import java.io.File;
 
29
import java.io.FileWriter;
29
30
import java.io.FileInputStream;
30
31
import java.io.OutputStream;
31
32
import java.io.InputStream;
79
80
    public void testVerify()
80
81
        throws SubversionException, IOException
81
82
    {
82
 
        OneTest thisTest = new OneTest(false);
 
83
        OneTest thisTest = new OneTest(false, true);
83
84
        admin.verify(thisTest.getRepository(), Revision.getInstance(0),
84
85
                     Revision.HEAD, null);
85
86
    }
86
87
 
87
 
    /* This test only tests the call down to the C++ layer. */
 
88
    private class VerifyCallback implements ReposVerifyCallback
 
89
    {
 
90
        public int mderr = 0;
 
91
        public int reverr = 0;
 
92
        public boolean keepGoing = false;
 
93
 
 
94
        public void onVerifyError(long revision, ClientException verifyError)
 
95
            throws ClientException
 
96
        {
 
97
            if (revision == Revision.SVN_INVALID_REVNUM) {
 
98
                ++mderr;
 
99
            }
 
100
            else {
 
101
                ++reverr;
 
102
            }
 
103
            if (keepGoing) {
 
104
                return;
 
105
            }
 
106
            else {
 
107
                throw verifyError;
 
108
            }
 
109
        }
 
110
 
 
111
    }
 
112
 
 
113
    private boolean tryToBreakRepo(OneTest test) throws IOException
 
114
    {
 
115
        File repo = test.getRepository();
 
116
 
 
117
        // Check for a sharded repo first
 
118
        File rev1 = new File(repo, "db/revs/0/1");
 
119
        if (!rev1.exists() || !rev1.setWritable(true))
 
120
        {
 
121
            // Try non-sharded
 
122
            rev1 = new File(repo, "db/revs/1");
 
123
        }
 
124
        if (!rev1.exists() || !rev1.setWritable(true))
 
125
            return false;
 
126
 
 
127
        FileWriter fd = new FileWriter(rev1);
 
128
        fd.write("inserting junk to corrupt the rev");
 
129
        fd.close();
 
130
        return true;
 
131
    }
 
132
 
 
133
    public void testVerifyBrokenRepo() throws Throwable
 
134
    {
 
135
        OneTest thisTest = new OneTest(false, true);
 
136
 
 
137
        if (!tryToBreakRepo(thisTest)) {
 
138
            // We don't support the repos format
 
139
            System.err.print("Cannot break repository for verify test.");
 
140
            return;
 
141
        }
 
142
 
 
143
        VerifyCallback cb = new VerifyCallback();
 
144
        cb.keepGoing = false;
 
145
 
 
146
        try {
 
147
            admin.verify(thisTest.getRepository(),
 
148
                         Revision.getInstance(0),
 
149
                         Revision.HEAD,
 
150
                         false, false, null, cb);
 
151
        }
 
152
        catch(ClientException ex) {
 
153
            assertEquals(cb.mderr, 1);
 
154
            assertEquals(cb.reverr, 0);
 
155
            return;
 
156
        }
 
157
 
 
158
        assert("Verify did not catch repository corruption." == "");
 
159
    }
 
160
 
 
161
    public void testVerifyBrokenRepo_KeepGoing() throws Throwable
 
162
    {
 
163
        OneTest thisTest = new OneTest(false, true);
 
164
 
 
165
        if (!tryToBreakRepo(thisTest)) {
 
166
            // We don't support the repos format
 
167
            System.err.print("Cannot break repository for verify test.");
 
168
            return;
 
169
        }
 
170
 
 
171
        VerifyCallback cb = new VerifyCallback();
 
172
        cb.keepGoing = true;
 
173
 
 
174
        admin.verify(thisTest.getRepository(),
 
175
                     Revision.getInstance(0),
 
176
                     Revision.HEAD,
 
177
                     false, false, null, cb);
 
178
 
 
179
        assertEquals(cb.mderr, 1);
 
180
        assertEquals(cb.reverr, 1);
 
181
    }
 
182
 
 
183
    /* this test only tests the call down to the C++ layer. */
88
184
    public void testUpgrade()
89
185
        throws SubversionException, IOException
90
186
    {