-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OCI package type #386
- Loading branch information
1 parent
0a22d10
commit 0d2bc75
Showing
9 changed files
with
179 additions
and
6 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...in/java/org/jfrog/artifactory/client/model/repository/settings/OciRepositorySettings.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,8 @@ | ||
package org.jfrog.artifactory.client.model.repository.settings; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public interface OciRepositorySettings extends DockerRepositorySettings { | ||
|
||
} |
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
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
34 changes: 34 additions & 0 deletions
34
...rg/jfrog/artifactory/client/model/repository/settings/impl/OciRepositorySettingsImpl.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,34 @@ | ||
package org.jfrog.artifactory.client.model.repository.settings.impl; | ||
|
||
import org.jfrog.artifactory.client.model.PackageType; | ||
import org.jfrog.artifactory.client.model.impl.PackageTypeImpl; | ||
import org.jfrog.artifactory.client.model.repository.settings.OciRepositorySettings; | ||
|
||
public class OciRepositorySettingsImpl extends DockerRepositorySettingsImpl implements OciRepositorySettings { | ||
public static String defaultLayout = "simple-default"; | ||
|
||
public OciRepositorySettingsImpl() { | ||
super(); | ||
} | ||
|
||
public PackageType getPackageType() { | ||
return PackageTypeImpl.oci; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof OciRepositorySettingsImpl)) return false; | ||
if (!super.equals(o)) return false; | ||
|
||
OciRepositorySettingsImpl that = (OciRepositorySettingsImpl) o; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = super.hashCode(); | ||
return result; | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
services/src/test/groovy/org/jfrog/artifactory/client/OciPackageTypeRepositoryTests.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,129 @@ | ||
package org.jfrog.artifactory.client | ||
|
||
import org.hamcrest.CoreMatchers | ||
import org.jfrog.artifactory.client.model.RepositoryType | ||
import org.jfrog.artifactory.client.model.repository.settings.RepositorySettings | ||
import org.jfrog.artifactory.client.model.repository.settings.docker.DockerApiVersion | ||
import org.jfrog.artifactory.client.model.repository.settings.impl.OciRepositorySettingsImpl | ||
import org.testng.annotations.BeforeMethod | ||
import org.testng.annotations.Test | ||
|
||
/** | ||
* test that client correctly sends and receives repository configuration with `oci` package type | ||
* | ||
*/ | ||
class OciPackageTypeRepositoryTests extends BaseRepositoryTests { | ||
|
||
OciPackageTypeRepositoryTests() { | ||
remoteRepoUrl = "https://registry-1.docker.io" | ||
} | ||
|
||
@Override | ||
RepositorySettings getRepositorySettings(RepositoryType repositoryType) { | ||
def settings = new OciRepositorySettingsImpl() | ||
|
||
settings.with { | ||
// local | ||
dockerApiVersion = DockerApiVersion.V2 | ||
dockerTagRetention = Math.abs(rnd.nextInt()) | ||
|
||
// remote | ||
enableTokenAuthentication = rnd.nextBoolean() | ||
listRemoteFolderItems = rnd.nextBoolean() | ||
} | ||
|
||
return settings | ||
} | ||
|
||
@BeforeMethod | ||
protected void setUp() { | ||
storeArtifactsLocallyInRemoteRepo = true | ||
super.setUp() | ||
} | ||
|
||
@Test(groups = "ociPackageTypeRepo") | ||
void testOciLocalRepo() { | ||
artifactory.repositories().create(0, localRepo) | ||
def expectedSettings = localRepo.repositorySettings | ||
|
||
def resp = artifactory.repository(localRepo.getKey()).get() | ||
assertThat(resp, CoreMatchers.notNullValue()) | ||
assertThat(resp.repoLayoutRef, CoreMatchers.is(OciRepositorySettingsImpl.defaultLayout)) | ||
resp.getRepositorySettings().with { | ||
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType())) | ||
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout())) | ||
|
||
// local | ||
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion())) | ||
assertThat(dockerTagRetention, CoreMatchers.is(expectedSettings.getDockerTagRetention())) | ||
|
||
// remote | ||
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue())) | ||
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue())) | ||
} | ||
} | ||
|
||
@Test(groups = "ociPackageTypeRepo") | ||
void testOciFederatedRepo() { | ||
artifactory.repositories().create(0, federatedRepo) | ||
def expectedSettings = federatedRepo.repositorySettings | ||
|
||
def resp = artifactory.repository(federatedRepo.getKey()).get() | ||
assertThat(resp, CoreMatchers.notNullValue()) | ||
assertThat(resp.repoLayoutRef, CoreMatchers.is(OciRepositorySettingsImpl.defaultLayout)) | ||
resp.getRepositorySettings().with { | ||
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType())) | ||
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout())) | ||
|
||
// local | ||
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion())) | ||
|
||
// remote | ||
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue())) | ||
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue())) | ||
} | ||
} | ||
|
||
@Test(groups = "ociPackageTypeRepo") | ||
void testOciRemoteRepo() { | ||
artifactory.repositories().create(0, remoteRepo) | ||
def expectedSettings = remoteRepo.repositorySettings | ||
|
||
def resp = artifactory.repository(remoteRepo.getKey()).get() | ||
assertThat(resp, CoreMatchers.notNullValue()) | ||
assertThat(resp.repoLayoutRef, CoreMatchers.is(OciRepositorySettingsImpl.defaultLayout)) | ||
resp.getRepositorySettings().with { | ||
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType())) | ||
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout())) | ||
|
||
// local | ||
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion())) | ||
// always in resp payload | ||
|
||
// remote | ||
assertThat(enableTokenAuthentication, CoreMatchers.is(expectedSettings.getEnableTokenAuthentication())) | ||
assertThat(listRemoteFolderItems, CoreMatchers.is(expectedSettings.getListRemoteFolderItems())) | ||
} | ||
} | ||
|
||
@Test(groups = "ociPackageTypeRepo") | ||
void testDockerVirtualRepo() { | ||
artifactory.repositories().create(0, virtualRepo) | ||
def expectedSettings = virtualRepo.repositorySettings | ||
|
||
def resp = artifactory.repository(virtualRepo.getKey()).get() | ||
assertThat(resp, CoreMatchers.notNullValue()) | ||
assertThat(resp.repoLayoutRef, CoreMatchers.is(OciRepositorySettingsImpl.defaultLayout)) | ||
resp.getRepositorySettings().with { | ||
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType())) | ||
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout())) | ||
|
||
// local | ||
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion())) | ||
|
||
// remote | ||
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue())) | ||
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue())) | ||
} | ||
} | ||
} |