Search in sources :

Example 1 with SubjectAccessReviewResponse

use of io.fabric8.openshift.api.model.SubjectAccessReviewResponse in project kubernetes-client by fabric8io.

the class SubjectAccessReviewTest method testCreate.

@Test
void testCreate() {
    server.expect().withPath("/apis/authorization.openshift.io/v1/subjectaccessreviews").andReturn(201, new SubjectAccessReviewResponseBuilder().withReason("r1").build()).once();
    SubjectAccessReviewResponse response = client.inAnyNamespace().subjectAccessReviews().create(new SubjectAccessReviewBuilder().build());
    assertNotNull(response);
    assertEquals("r1", response.getReason());
}
Also used : SubjectAccessReviewResponseBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewResponseBuilder) SubjectAccessReviewResponse(io.fabric8.openshift.api.model.SubjectAccessReviewResponse) LocalSubjectAccessReviewBuilder(io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder) SubjectAccessReviewBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with SubjectAccessReviewResponse

use of io.fabric8.openshift.api.model.SubjectAccessReviewResponse in project kubernetes-client by fabric8io.

the class SubjectAccessReviewTest method testCreateLocal.

@Test
void testCreateLocal() {
    server.expect().withPath("/apis/authorization.openshift.io/v1/namespaces/test/localsubjectaccessreviews").andReturn(201, new SubjectAccessReviewResponseBuilder().withReason("r1").build()).once();
    SubjectAccessReviewResponse response = client.localSubjectAccessReviews().inNamespace("test").create(new LocalSubjectAccessReviewBuilder().withNamespace("test").withVerb("get").withGroups("test.fabric8.io").build());
    assertNotNull(response);
    assertEquals("r1", response.getReason());
}
Also used : SubjectAccessReviewResponseBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewResponseBuilder) LocalSubjectAccessReviewBuilder(io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder) SubjectAccessReviewResponse(io.fabric8.openshift.api.model.SubjectAccessReviewResponse) Test(org.junit.jupiter.api.Test)

Example 3 with SubjectAccessReviewResponse

use of io.fabric8.openshift.api.model.SubjectAccessReviewResponse in project kubernetes-client by fabric8io.

the class SubjectAccessReviewTest method testCreateInLine.

@Test
void testCreateInLine() {
    server.expect().withPath("/apis/authorization.openshift.io/v1/subjectaccessreviews").andReturn(201, new SubjectAccessReviewResponseBuilder().withReason("r2").build()).once();
    SubjectAccessReviewResponse response = client.inAnyNamespace().subjectAccessReviews().create(new SubjectAccessReviewBuilder().build());
    assertNotNull(response);
    assertEquals("r2", response.getReason());
}
Also used : SubjectAccessReviewResponseBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewResponseBuilder) SubjectAccessReviewResponse(io.fabric8.openshift.api.model.SubjectAccessReviewResponse) LocalSubjectAccessReviewBuilder(io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder) SubjectAccessReviewBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with SubjectAccessReviewResponse

use of io.fabric8.openshift.api.model.SubjectAccessReviewResponse in project kubernetes-client by fabric8io.

the class SubjectAccessReviewTest method testCreateLocalInLine.

@Test
void testCreateLocalInLine() {
    server.expect().withPath("/apis/authorization.openshift.io/v1/namespaces/test/localsubjectaccessreviews").andReturn(201, new SubjectAccessReviewResponseBuilder().withReason("r2").build()).once();
    SubjectAccessReviewResponse response = client.localSubjectAccessReviews().inNamespace("test").create(new LocalSubjectAccessReviewBuilder().withUser("user").withVerb("verb").build());
    assertNotNull(response);
    assertEquals("r2", response.getReason());
}
Also used : SubjectAccessReviewResponseBuilder(io.fabric8.openshift.api.model.SubjectAccessReviewResponseBuilder) LocalSubjectAccessReviewBuilder(io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder) SubjectAccessReviewResponse(io.fabric8.openshift.api.model.SubjectAccessReviewResponse) Test(org.junit.jupiter.api.Test)

Example 5 with SubjectAccessReviewResponse

use of io.fabric8.openshift.api.model.SubjectAccessReviewResponse in project kubernetes-client by fabric8io.

the class OpenShiftAuthorizationIT method createLocalSubjectAccessReview.

@Test
public void createLocalSubjectAccessReview() {
    // Given
    LocalSubjectAccessReview localSubjectAccessReview = new LocalSubjectAccessReviewBuilder().withNamespace(session.getNamespace()).withVerb("get").withResource("pods").build();
    // When
    SubjectAccessReviewResponse response = client.localSubjectAccessReviews().inNamespace(session.getNamespace()).create(localSubjectAccessReview);
    // Then
    assertNotNull(response);
    assertTrue(response.getAllowed());
}
Also used : LocalSubjectAccessReviewBuilder(io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder) SubjectAccessReviewResponse(io.fabric8.openshift.api.model.SubjectAccessReviewResponse) LocalSubjectAccessReview(io.fabric8.openshift.api.model.LocalSubjectAccessReview) Test(org.junit.Test)

Aggregations

SubjectAccessReviewResponse (io.fabric8.openshift.api.model.SubjectAccessReviewResponse)7 LocalSubjectAccessReviewBuilder (io.fabric8.openshift.api.model.LocalSubjectAccessReviewBuilder)6 SubjectAccessReviewBuilder (io.fabric8.openshift.api.model.SubjectAccessReviewBuilder)4 SubjectAccessReviewResponseBuilder (io.fabric8.openshift.api.model.SubjectAccessReviewResponseBuilder)4 Test (org.junit.jupiter.api.Test)4 Test (org.junit.Test)3 LocalSubjectAccessReview (io.fabric8.openshift.api.model.LocalSubjectAccessReview)2 SubjectAccessReview (io.fabric8.openshift.api.model.SubjectAccessReview)2