Search in sources :

Example 1 with Base64Encoded

use of org.cactoos.text.Base64Encoded in project artipie by artipie.

the class AuthAndPermissionsTest method johnCanDelete.

@Test
void johnCanDelete() throws IOException {
    final RsStatus status = RsStatus.NO_CONTENT;
    MatcherAssert.assertThat(new BasicAuthSlice(new SliceSimple(new RsWithStatus(status)), new AuthFromYaml(this.credentials()), new Permission.ByName("delete", this.permissions())).response(new RequestLine("PUT", "/foo", "HTTP/1.2").toString(), new ListOf<Map.Entry<String, String>>(new Authorization(String.format("Basic %s", new Base64Encoded("john:123").asString()))), Flowable.empty()), new RsHasStatus(status));
}
Also used : RsHasStatus(com.artipie.http.hm.RsHasStatus) RsStatus(com.artipie.http.rs.RsStatus) Authorization(com.artipie.http.headers.Authorization) BasicAuthSlice(com.artipie.http.auth.BasicAuthSlice) RequestLine(com.artipie.http.rq.RequestLine) RsWithStatus(com.artipie.http.rs.RsWithStatus) Permission(com.artipie.http.auth.Permission) ListOf(org.cactoos.list.ListOf) Base64Encoded(org.cactoos.text.Base64Encoded) Map(java.util.Map) SliceSimple(com.artipie.http.slice.SliceSimple) Test(org.junit.jupiter.api.Test)

Example 2 with Base64Encoded

use of org.cactoos.text.Base64Encoded in project artipie by artipie.

the class AuthAndPermissionsTest method publicRepoWorksWithAuth.

@Test
void publicRepoWorksWithAuth() throws IOException {
    final RsStatus status = RsStatus.OK;
    MatcherAssert.assertThat(new BasicAuthSlice(new SliceSimple(new RsWithStatus(status)), new AuthFromYaml(this.credentials()), new Permission.ByName("delete", this.allAllowedPermissions())).response(new RequestLine("GET", "/foo", "HTTP/1.2").toString(), new ListOf<Map.Entry<String, String>>(new Authorization(String.format("Basic %s", new Base64Encoded("admin:abc").asString()))), Flowable.empty()), new RsHasStatus(status));
}
Also used : RsHasStatus(com.artipie.http.hm.RsHasStatus) RsStatus(com.artipie.http.rs.RsStatus) Authorization(com.artipie.http.headers.Authorization) BasicAuthSlice(com.artipie.http.auth.BasicAuthSlice) RequestLine(com.artipie.http.rq.RequestLine) RsWithStatus(com.artipie.http.rs.RsWithStatus) Permission(com.artipie.http.auth.Permission) ListOf(org.cactoos.list.ListOf) Base64Encoded(org.cactoos.text.Base64Encoded) Map(java.util.Map) SliceSimple(com.artipie.http.slice.SliceSimple) Test(org.junit.jupiter.api.Test)

Example 3 with Base64Encoded

use of org.cactoos.text.Base64Encoded in project artipie by artipie.

the class AuthAndPermissionsTest method adminCanDeploy.

@Test
void adminCanDeploy() throws IOException {
    final RsStatus status = RsStatus.ACCEPTED;
    MatcherAssert.assertThat(new BasicAuthSlice(new SliceSimple(new RsWithStatus(status)), new AuthFromYaml(this.credentials()), new Permission.ByName("deploy", this.permissions())).response(new RequestLine("PUT", "/foo", "HTTP/1.2").toString(), new ListOf<Map.Entry<String, String>>(new Authorization(String.format("Basic %s", new Base64Encoded("admin:abc").asString()))), Flowable.empty()), new RsHasStatus(status));
}
Also used : RsHasStatus(com.artipie.http.hm.RsHasStatus) RsStatus(com.artipie.http.rs.RsStatus) Authorization(com.artipie.http.headers.Authorization) BasicAuthSlice(com.artipie.http.auth.BasicAuthSlice) RequestLine(com.artipie.http.rq.RequestLine) RsWithStatus(com.artipie.http.rs.RsWithStatus) Permission(com.artipie.http.auth.Permission) ListOf(org.cactoos.list.ListOf) Base64Encoded(org.cactoos.text.Base64Encoded) Map(java.util.Map) SliceSimple(com.artipie.http.slice.SliceSimple) Test(org.junit.jupiter.api.Test)

Example 4 with Base64Encoded

use of org.cactoos.text.Base64Encoded in project artipie by artipie.

the class GemITCase method gemPushAndInstallWorks.

@Test
void gemPushAndInstallWorks() throws IOException {
    this.containers.assertExec("Packages was not pushed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>("POST http://artipie:8080/my-gem/api/v1/gems", "201 Created"))), "env", String.format("GEM_HOST_API_KEY=%s", new Base64Encoded("any:any").asString()), "gem", "push", "-v", "/w/rails-6.0.2.2.gem", "--host", "http://artipie:8080/my-gem");
    this.containers.assertArtipieContent("Package was not added to storage", String.format("/var/artipie/data/my-gem/gems/%s", GemITCase.RAILS), new IsEqual<>(new TestResource(String.format("gem/%s", GemITCase.RAILS)).asBytes()));
    this.containers.assertExec("rubygems.org was not removed from sources", new ContainerResultMatcher(), "gem", "sources", "--remove", "https://rubygems.org/");
    this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>(String.format("GET http://artipie:8080/my-gem/quick/Marshal.4.8/%sspec.rz", GemITCase.RAILS), "200 OK", "Successfully installed rails-6.0.2.2", "1 gem installed"))), "gem", "install", GemITCase.RAILS, "--source", "http://artipie:8080/my-gem", "--ignore-dependencies", "-V");
}
Also used : StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) TestResource(com.artipie.asto.test.TestResource) Base64Encoded(org.cactoos.text.Base64Encoded) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Aggregations

Base64Encoded (org.cactoos.text.Base64Encoded)4 Test (org.junit.jupiter.api.Test)4 BasicAuthSlice (com.artipie.http.auth.BasicAuthSlice)3 Permission (com.artipie.http.auth.Permission)3 Authorization (com.artipie.http.headers.Authorization)3 RsHasStatus (com.artipie.http.hm.RsHasStatus)3 RequestLine (com.artipie.http.rq.RequestLine)3 RsStatus (com.artipie.http.rs.RsStatus)3 RsWithStatus (com.artipie.http.rs.RsWithStatus)3 SliceSimple (com.artipie.http.slice.SliceSimple)3 Map (java.util.Map)3 ListOf (org.cactoos.list.ListOf)3 TestResource (com.artipie.asto.test.TestResource)1 ContainerResultMatcher (com.artipie.test.ContainerResultMatcher)1 IsEqual (org.hamcrest.core.IsEqual)1 StringContainsInOrder (org.hamcrest.text.StringContainsInOrder)1