-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: b=master,r=35b7ea34980746e5881a9bd85ea96aa9d8585184,t=2017-…
…03-31-1219-21995
- Loading branch information
1 parent
e786d42
commit 1a6f7ac
Showing
8 changed files
with
155 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...nd-plugin/src/main/java/org/sonatype/nexus/wonderland/rest/WonderlandResourceSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.wonderland.rest; | ||
|
||
import org.sonatype.nexus.util.SystemPropertiesHelper; | ||
import org.sonatype.sisu.goodies.common.ComponentSupport; | ||
import org.sonatype.sisu.siesta.common.Resource; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
/** | ||
* Support for wonderland resources. | ||
* | ||
* @since 2.14 | ||
*/ | ||
public abstract class WonderlandResourceSupport | ||
extends ComponentSupport | ||
implements Resource | ||
{ | ||
private boolean noPopUps = SystemPropertiesHelper.getBoolean("nexus.download.noPopUps", false); | ||
|
||
/** | ||
* Disable authTicket pop-ups? | ||
*/ | ||
protected boolean isNoPopUps() { | ||
return noPopUps; | ||
} | ||
|
||
@VisibleForTesting | ||
void setNoPopUps(final boolean noPopUps) { | ||
this.noPopUps = noPopUps; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...rland-plugin/src/test/java/org/sonatype/nexus/wonderland/rest/DownloadResourceTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.wonderland.rest | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
import javax.ws.rs.WebApplicationException | ||
|
||
import org.sonatype.nexus.util.Tokens | ||
import org.sonatype.nexus.wonderland.AuthTicketService | ||
import org.sonatype.nexus.wonderland.DownloadService | ||
import org.sonatype.sisu.litmus.testsupport.TestSupport | ||
|
||
import org.junit.Before | ||
import org.junit.Test | ||
import org.mockito.Mock | ||
|
||
import static org.mockito.Mockito.when | ||
|
||
/** | ||
* Test for {@link DownloadResource}. | ||
*/ | ||
class DownloadResourceTest | ||
extends TestSupport | ||
{ | ||
private static final String AUTH_TICKET = "a valid ticket" | ||
|
||
private static final String ZIP_NAME = "foo" | ||
|
||
@Mock | ||
private DownloadService downloadService | ||
|
||
@Mock | ||
private AuthTicketService authTickets | ||
|
||
private DownloadResource underTest | ||
|
||
@Before | ||
void setup() { | ||
when(authTickets.createTicket()).thenReturn(AUTH_TICKET) | ||
when(downloadService.get(ZIP_NAME, AUTH_TICKET)).thenReturn(util.createTempFile()) | ||
underTest = new DownloadResource(downloadService, authTickets) | ||
} | ||
|
||
@Test | ||
void downloadZipWithAuthTicketParam() { | ||
underTest.downloadZip(ZIP_NAME, Tokens.encodeBase64String(AUTH_TICKET.getBytes(StandardCharsets.UTF_8)), null) | ||
} | ||
|
||
@Test | ||
void downloadZipWithAuthTicketHeader() { | ||
underTest.downloadZip(ZIP_NAME, null, AUTH_TICKET) | ||
} | ||
|
||
@Test(expected = WebApplicationException.class) | ||
void downloadZipNoAuthTicket() { | ||
underTest.downloadZip(ZIP_NAME, null, null) | ||
} | ||
|
||
@Test | ||
void downloadZipNoAuthTicketNoPopUps() { | ||
underTest.setNoPopUps(true) | ||
underTest.downloadZip(ZIP_NAME, null, null) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b=master,r=dbc4629fbdd4be6dafb961da1f91f6d0b467e950,t=2017-03-29-1147-11872 | ||
b=master,r=35b7ea34980746e5881a9bd85ea96aa9d8585184,t=2017-03-31-1219-21995 |