-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurable user agent for retrieving metadata
- Loading branch information
1 parent
611d835
commit b450ab8
Showing
7 changed files
with
51 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ gui: | |
content: LOCAL | ||
|
||
metadata_import: | ||
useragent: "" | ||
auto_refresh: | ||
cronSchedule: "-" | ||
|
||
|
23 changes: 21 additions & 2 deletions
23
manage-server/src/test/java/manage/format/SaveURLResourceTest.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 |
---|---|---|
@@ -1,19 +1,38 @@ | ||
package manage.format; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
|
||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class SaveURLResourceTest { | ||
|
||
@Mock | ||
URLConnection connection; | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testNotAllowedProtocol() throws MalformedURLException { | ||
SaveURLResource resource = new SaveURLResource(new URL("file://local"), false); | ||
SaveURLResource resource = new SaveURLResource(new URL("file://local"), false, null); | ||
} | ||
|
||
@Test | ||
public void testNotAllowedProtocolInDev() throws MalformedURLException { | ||
new SaveURLResource(new URL("file://local"), true); | ||
new SaveURLResource(new URL("file://local"), true, null); | ||
} | ||
|
||
@Test | ||
public void testUseUserAgent() throws IOException { | ||
SaveURLResource resource = new SaveURLResource(new URL("https://external"), false, "user agent"); | ||
resource.customizeConnection(connection); | ||
verify(connection, times(1)).setRequestProperty("User-Agent", "user agent"); | ||
} | ||
} |
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