Skip to content

Commit

Permalink
refactor: use api.nyk.io as default url
Browse files Browse the repository at this point in the history
`snyk.io/api` is the legacy and deprecated way to access Snyk APIs.
Let's default to `api.snyk.io` instead.
  • Loading branch information
jlourenc committed Jul 13, 2024
1 parent 783fe6b commit a4a0768
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ snyk.api.organization=

# The base URL for all Snyk API endpoints.
# Documentation: https://snyk.docs.apiary.io/#introduction/api-url
# Default: https://snyk.io/api/v1/
#snyk.api.url=https://snyk.io/api/v1/
# Default: https://api.snyk.io/v1/
#snyk.api.url=https://api.snyk.io/v1/

# Path to an SSL Certificate for Snyk API in PEM format.
#snyk.api.sslCertificatePath=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public enum PluginConfiguration implements Configuration {
// general settings
API_URL("snyk.api.url", "https://snyk.io/api/v1/"),
API_URL("snyk.api.url", "https://api.snyk.io/v1/"),
API_TOKEN("snyk.api.token", ""),
API_ORGANIZATION("snyk.api.organization", ""),
API_SSL_CERTIFICATE_PATH("snyk.api.sslCertificatePath", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PluginConfigurationTest {
@Test
void checkDefaultValues() {
assertAll("should be not empty",
() -> assertEquals("https://snyk.io/api/v1/", API_URL.defaultValue(), getAssertionMessage(API_URL, "default value must be 'https://snyk.io/api/v1/'")),
() -> assertEquals("https://api.snyk.io/v1/", API_URL.defaultValue(), getAssertionMessage(API_URL, "default value must be 'https://api.snyk.io/v1/'")),
() -> assertEquals("false", SCANNER_BLOCK_ON_API_FAILURE.defaultValue(), getAssertionMessage(SCANNER_BLOCK_ON_API_FAILURE, "default value must be 'false'")),
() -> assertEquals("low", SCANNER_VULNERABILITY_THRESHOLD.defaultValue(), getAssertionMessage(SCANNER_VULNERABILITY_THRESHOLD, "default value must be 'low'")),
() -> assertEquals("low", SCANNER_LICENSE_THRESHOLD.defaultValue(), getAssertionMessage(SCANNER_LICENSE_THRESHOLD, "default value must be 'low'"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
snyk.api.url=https://snyk.io/api/v1/
snyk.api.url=https://api.snyk.io/v1/
snyk.api.token=my-api-token
snyk.api.organization=my-api-organization
#
Expand Down
2 changes: 1 addition & 1 deletion helm-install/install-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pushd "$SCRIPT_DIR/.." || exit 1
if [[ $SNYK_TOKEN == "" ]]; then
$SNYK auth
fi
ORG=$(curl -s -H "Authorization: token $SNYK_TOKEN" https://snyk.io/api/v1/orgs | jq -r '.orgs|first|.id')
ORG=$(curl -s -H "Authorization: token $SNYK_TOKEN" https://api.snyk.io/v1/orgs | jq -r '.orgs|first|.id')

# monkey patching config file
pushd plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void createSnykClient_shouldThrowIAE_ifTokenIsNull() {
void createSnykConfig_shouldReturnDefaultValues_ifNotDefined() {
Config config = new Config("snyk-api-token");

assertEquals("https://snyk.io/api/v1/", config.baseUrl);
assertEquals("https://api.snyk.io/v1/", config.baseUrl);
assertEquals("snyk-sdk-java", config.userAgent);
}

Expand Down
2 changes: 1 addition & 1 deletion snyk-sdk/src/main/java/io/snyk/sdk/SnykConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static SnykConfig withDefaults() {

public static class Builder {
private String token;
private String baseUrl = "https://snyk.io/api/v1/";
private String baseUrl = "https://api.snyk.io/v1/";
private String userAgent = "snyk-sdk-java";
private boolean trustAllCertificates = false;
private String sslCertificatePath = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void shouldIncludeBaseUrlWithPath() {
assertEquals(SnykHttpRequestBuilder.create(configWithDefaultBaseUrl)
.build()
.uri().toString(),
"https://snyk.io/api/v1/");
"https://api.snyk.io/v1/");

String otherBaseUrl = "https://other-host/some-prefix/";
SnykConfig configWithDifferentBaseUrl = SnykConfig.newBuilder().setBaseUrl(otherBaseUrl).build();
Expand All @@ -34,7 +34,7 @@ void shouldIncludeBaseUrlWithPath() {
void shouldOnlyIncludeNonNullQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();

assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", "abc123")
Expand All @@ -48,7 +48,7 @@ void shouldOnlyIncludeNonNullQueryParameters() {
@Test
void shouldOnlyIncludePresentQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();
assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", Optional.of("abc123"))
Expand All @@ -62,7 +62,7 @@ void shouldOnlyIncludePresentQueryParameters() {
@Test
void shouldIncludeMultipleQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();
assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123&foo=bar",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123&foo=bar",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", "abc123")
Expand Down

0 comments on commit a4a0768

Please sign in to comment.