Skip to content

Commit

Permalink
GH-164 Fix LookupControllerTest and release 2.7.1 (Resolve #165)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Jul 19, 2020
1 parent dafd8ca commit c00598a
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/docs/docker.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
</ul>
<h2><a class="anchor" aria-hidden="true" id="installation"></a><a href="#installation" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation</h2>
<p>First of all, you have to pull the image from <a href="https://hub.docker.com/r/dzikoysk/reposilite">DockerHub</a>:</p>
<pre><code class="hljs css language-shell-session"><span class="hljs-comment">// released builds, e.g. 2.7.0</span>
$ docker pull dzikoysk/reposilite:<span class="hljs-number">2.7</span><span class="hljs-number">.0</span>
<pre><code class="hljs css language-shell-session"><span class="hljs-comment">// released builds, e.g. 2.7.1</span>
$ docker pull dzikoysk/reposilite:<span class="hljs-number">2.7</span><span class="hljs-number">.1</span>

<span class="hljs-comment">// nightly builds</span>
$ docker pull dzikoysk/reposilite:nightly
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/docker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
</ul>
<h2><a class="anchor" aria-hidden="true" id="installation"></a><a href="#installation" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation</h2>
<p>First of all, you have to pull the image from <a href="https://hub.docker.com/r/dzikoysk/reposilite">DockerHub</a>:</p>
<pre><code class="hljs css language-shell-session"><span class="hljs-comment">// released builds, e.g. 2.7.0</span>
$ docker pull dzikoysk/reposilite:<span class="hljs-number">2.7</span><span class="hljs-number">.0</span>
<pre><code class="hljs css language-shell-session"><span class="hljs-comment">// released builds, e.g. 2.7.1</span>
$ docker pull dzikoysk/reposilite:<span class="hljs-number">2.7</span><span class="hljs-number">.1</span>

<span class="hljs-comment">// nightly builds</span>
$ docker pull dzikoysk/reposilite:nightly
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>org.panda-lang</groupId>
<artifactId>reposilite-parent</artifactId>
<packaging>pom</packaging>
<version>2.7.0</version>
<version>2.7.1</version>

<modules>
<module>reposilite-backend</module>
Expand Down
2 changes: 1 addition & 1 deletion reposilite-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<artifactId>reposilite-parent</artifactId>
<groupId>org.panda-lang</groupId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public final class ReposiliteConstants {

public static final String VERSION = "2.7.0";
public static final String VERSION = "2.7.1";

public static final String REMOTE_VERSION = "https://repo.panda-lang.org/org/panda-lang/reposilite/latest";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
package org.panda_lang.reposilite.auth;

import io.javalin.http.Context;
import org.apache.http.HttpStatus;
import org.jetbrains.annotations.Nullable;
import org.panda_lang.reposilite.Reposilite;
import org.panda_lang.reposilite.api.ErrorDto;
import org.panda_lang.reposilite.config.Configuration;
import org.panda_lang.reposilite.repository.Repository;
import org.panda_lang.reposilite.repository.RepositoryService;
Expand All @@ -43,36 +45,36 @@ public Authenticator(Configuration configuration, RepositoryService repositorySe
this.tokenService = tokenService;
}

public Result<Pair<String[], Repository>, String> authDefaultRepository(Context context, String uri) {
public Result<Pair<String[], Repository>, ErrorDto> authDefaultRepository(Context context, String uri) {
return authRepository(context, RepositoryUtils.normalizeUri(configuration, repositoryService, uri));
}

public Result<Pair<String[], Repository>, String> authRepository(Context context, String uri) {
public Result<Pair<String[], Repository>, ErrorDto> authRepository(Context context, String uri) {
String[] path = StringUtils.split(uri, "/");

// discard invalid requests (less than 'repository/group/artifact')
if (path.length < 1) {
return Result.error("Unsupported request");
return Result.error(new ErrorDto(HttpStatus.SC_OK, "Unsupported request"));
}

String repositoryName = path[0];

if (StringUtils.isEmpty(repositoryName)) {
return Result.error("Unsupported request");
return Result.error(new ErrorDto(HttpStatus.SC_OK, "Unsupported request"));
}

Repository repository = repositoryService.getRepository(path[0]);

if (repository == null) {
return Result.error("Repository " + path[0] + " not found");
return Result.error(new ErrorDto(HttpStatus.SC_OK, "Repository " + path[0] + " not found"));
}

// auth hidden repositories
if (repository.isHidden()) {
Result<Session, String> authResult = authDefault(context);

if (authResult.containsError()) {
return Result.error("Unauthorized request");
return Result.error(new ErrorDto(HttpStatus.SC_UNAUTHORIZED, "Unauthorized request"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.http.HttpStatus;
import org.panda_lang.reposilite.Reposilite;
import org.panda_lang.reposilite.RepositoryController;
import org.panda_lang.reposilite.api.ErrorDto;
import org.panda_lang.reposilite.api.ErrorUtils;
import org.panda_lang.reposilite.auth.Authenticator;
import org.panda_lang.reposilite.config.Configuration;
Expand Down Expand Up @@ -56,7 +57,7 @@ public Context handleContext(Context context) {
return context.json(listRepositories(context));
}

Result<Pair<String[], Repository>, String> result = authenticator.authRepository(context, uri);
Result<Pair<String[], Repository>, ErrorDto> result = authenticator.authRepository(context, uri);

if (result.containsError()) {
return ErrorUtils.error(context, HttpStatus.SC_UNAUTHORIZED, "Unauthorized request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public LookupService(Reposilite reposilite) {
}

protected Result<Context, ErrorDto> serveLocal(Context context) {
Result<Pair<String[], Repository>, String> result = this.authenticator.authDefaultRepository(context, context.req.getRequestURI());
Result<Pair<String[], Repository>, ErrorDto> result = this.authenticator.authDefaultRepository(context, context.req.getRequestURI());

if (result.containsError()) {
return Result.error(new ErrorDto(HttpStatus.SC_UNAUTHORIZED, result.getError()));
return Result.error(result.getError());
}

String[] path = result.getValue().getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ void shouldReturn200AndHeadRequestedFile() throws IOException {
}

@Test
void shouldReturn200WithUnauthorizedMessage() throws IOException {
assertResponseWithMessage(super.get("/private/a/b"), HttpStatus.SC_OK, "Unauthorized request");
void shouldReturn401WithUnauthorizedMessage() throws IOException {
assertResponseWithMessage(super.get("/private/a/b"), HttpStatus.SC_UNAUTHORIZED, "Unauthorized request");
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions reposilite-site/docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Reposilite defines two types of builds:
First of all, you have to pull the image from [DockerHub](https://hub.docker.com/r/dzikoysk/reposilite):

```shell-session
// released builds, e.g. 2.7.0
$ docker pull dzikoysk/reposilite:2.7.0
// released builds, e.g. 2.7.1
$ docker pull dzikoysk/reposilite:2.7.1
// nightly builds
$ docker pull dzikoysk/reposilite:nightly
Expand Down

0 comments on commit c00598a

Please sign in to comment.