Extend LFS plugin servlet so that Git LFS 2.0 Lock API is handled
The change extends LFS serve regex so that the following operations are handled (according to [1]): POST /locks - create lock GET /locks - list locks POST /locks/verify - list locks for verification POST /locks/lock_id/unlock - delete lock Common LFS definitions, like paths, regexps, content type, etc., were moved to gerrit-extension-api so that they can be shared between Gerrit core and LFS plugin. [1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md Change-Id: I8299000c827b5a34d6de1ed5fc650f74be4164a2 Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
committed by
David Pursehouse
parent
2c60b89e2b
commit
8939ee8602
@@ -1,56 +0,0 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.plugins;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LfsPluginServletTest {
|
||||
|
||||
@Test
|
||||
public void noLfsEndPoint_noMatch() {
|
||||
Pattern p = Pattern.compile(LfsPluginServlet.URL_REGEX);
|
||||
doesNotMatch(p, "/foo");
|
||||
doesNotMatch(p, "/a/foo");
|
||||
doesNotMatch(p, "/p/foo");
|
||||
doesNotMatch(p, "/a/p/foo");
|
||||
|
||||
doesNotMatch(p, "/info/lfs/objects/batch");
|
||||
doesNotMatch(p, "/info/lfs/objects/batch/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchingLfsEndpoint_projectNameCaptured() {
|
||||
Pattern p = Pattern.compile(LfsPluginServlet.URL_REGEX);
|
||||
matches(p, "/foo/bar/info/lfs/objects/batch", "foo/bar");
|
||||
matches(p, "/a/foo/bar/info/lfs/objects/batch", "foo/bar");
|
||||
matches(p, "/p/foo/bar/info/lfs/objects/batch", "foo/bar");
|
||||
matches(p, "/a/p/foo/bar/info/lfs/objects/batch", "foo/bar");
|
||||
}
|
||||
|
||||
private void doesNotMatch(Pattern p, String input) {
|
||||
Matcher m = p.matcher(input);
|
||||
assertThat(m.matches()).isFalse();
|
||||
}
|
||||
|
||||
private void matches(Pattern p, String input, String expectedProjectName) {
|
||||
Matcher m = p.matcher(input);
|
||||
assertThat(m.matches()).isTrue();
|
||||
assertThat(m.group(1)).isEqualTo(expectedProjectName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user