Search in sources :

Example 1 with Scope

use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project bgpcep by opendaylight.

the class ConnectedGraphServer method createConnectedGraph.

@Override
public ConnectedGraph createConnectedGraph(final String name, final DomainScope scope) {
    Graph graph = new GraphBuilder().setName(name).setDomainScope(scope).build();
    addToDataStore(getGraphInstanceIdentifier(name), graph, "Graph(" + name + ")");
    ConnectedGraphImpl cgraph = new ConnectedGraphImpl(graph, this);
    graphs.put(graph.key(), cgraph);
    return cgraph;
}
Also used : ConnectedGraph(org.opendaylight.graph.ConnectedGraph) Graph(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph) GraphBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.GraphBuilder)

Example 2 with Scope

use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.

the class ScopeResourceTest method shouldGetScope_wrongDomain.

@Test
public void shouldGetScope_wrongDomain() {
    final String domainId = "domain-id";
    final Domain mockDomain = new Domain();
    mockDomain.setId(domainId);
    final String scopeId = "scope-id";
    final Scope mockScope = new Scope();
    mockScope.setId(scopeId);
    mockScope.setKey(scopeId);
    mockScope.setName("scope-name");
    mockScope.setDomain("wrong-domain");
    doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
    doReturn(Maybe.just(mockScope)).when(scopeService).findById(scopeId);
    final Response response = target("domains").path(domainId).path("scopes").path(scopeId).request().get();
    assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Scope(io.gravitee.am.model.oauth2.Scope) Domain(io.gravitee.am.model.Domain) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest) Test(org.junit.Test)

Example 3 with Scope

use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.

the class ScopesResourceTest method shouldCreate.

@Test
public void shouldCreate() {
    final String domainId = "domain-1";
    final Domain mockDomain = new Domain();
    mockDomain.setId(domainId);
    NewScope newScope = new NewScope();
    newScope.setKey("scope-key");
    newScope.setName("scope-name");
    newScope.setDescription("scope-description");
    Scope scope = new Scope();
    scope.setId("scope-id");
    scope.setKey("scope-key");
    scope.setName("scope-name");
    doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
    doReturn(Single.just(scope)).when(scopeService).create(eq(domainId), any(NewScope.class), any());
    final Response response = target("domains").path(domainId).path("scopes").request().post(Entity.json(newScope));
    assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) NewScope(io.gravitee.am.service.model.NewScope) Scope(io.gravitee.am.model.oauth2.Scope) NewScope(io.gravitee.am.service.model.NewScope) Domain(io.gravitee.am.model.Domain) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 4 with Scope

use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.

the class ScopesResourceTest method shouldGetScopes.

@Test
public void shouldGetScopes() {
    final String domainId = "domain-1";
    final Scope mockScope = new Scope();
    mockScope.setId("scope-1-id");
    mockScope.setKey("scope-1-id");
    mockScope.setName("scope-1-name");
    mockScope.setDomain(domainId);
    final Scope mockScope2 = new Scope();
    mockScope2.setId("scope-2-id");
    mockScope2.setKey("scope-2-id");
    mockScope2.setName("scope-2-name");
    mockScope2.setDomain(domainId);
    final Set<Scope> scopes = new HashSet<>(Arrays.asList(mockScope, mockScope2));
    doReturn(Single.just(new Page<>(scopes, 0, 2))).when(scopeService).findByDomain(domainId, 0, 50);
    final Response response = target("domains").path(domainId).path("scopes").request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    String body = response.readEntity(String.class);
    JsonArray data = new JsonObject(body).getJsonArray("data");
    assertTrue(data.size() == 2);
}
Also used : Response(javax.ws.rs.core.Response) JsonArray(io.vertx.core.json.JsonArray) NewScope(io.gravitee.am.service.model.NewScope) Scope(io.gravitee.am.model.oauth2.Scope) JsonObject(io.vertx.core.json.JsonObject) Page(io.gravitee.am.model.common.Page) HashSet(java.util.HashSet) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 5 with Scope

use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.

the class UserConsentsResourceTest method shouldGetUserConsents.

@Test
public void shouldGetUserConsents() {
    final String domainId = "domain-1";
    final Domain mockDomain = new Domain();
    mockDomain.setId(domainId);
    final User mockUser = new User();
    mockUser.setId("user-id-1");
    final Application mockClient = new Application();
    mockClient.setId("client-id-1");
    final Scope mockScope = new Scope();
    mockScope.setId("scope-id-1");
    mockScope.setKey("scope");
    final ScopeApproval scopeApproval = new ScopeApproval();
    scopeApproval.setUserId("user-id-1");
    scopeApproval.setClientId("clientId");
    scopeApproval.setScope("scope");
    scopeApproval.setDomain(domainId);
    doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
    doReturn(Maybe.just(mockClient)).when(applicationService).findByDomainAndClientId(domainId, scopeApproval.getClientId());
    doReturn(Maybe.just(mockScope)).when(scopeService).findByDomainAndKey(domainId, scopeApproval.getScope());
    doReturn(Flowable.just(scopeApproval)).when(scopeApprovalService).findByDomainAndUser(domainId, mockUser.getId());
    final Response response = target("domains").path(domainId).path("users").path(mockUser.getId()).path("consents").request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) User(io.gravitee.am.model.User) Scope(io.gravitee.am.model.oauth2.Scope) Domain(io.gravitee.am.model.Domain) Application(io.gravitee.am.model.Application) ScopeApproval(io.gravitee.am.model.oauth2.ScopeApproval) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Aggregations

Scope (io.gravitee.am.model.oauth2.Scope)63 Test (org.junit.Test)43 TestObserver (io.reactivex.observers.TestObserver)25 Event (io.gravitee.am.model.common.event.Event)16 Page (io.gravitee.am.model.common.Page)15 Domain (io.gravitee.am.model.Domain)10 NewScope (io.gravitee.am.service.model.NewScope)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 AbstractManagementTest (io.gravitee.am.repository.management.AbstractManagementTest)8 Maybe (io.reactivex.Maybe)8 Single (io.reactivex.Single)8 RandomString (io.gravitee.am.common.utils.RandomString)7 ScopeRepository (io.gravitee.am.repository.management.api.ScopeRepository)7 Completable (io.reactivex.Completable)7 JerseySpringTest (io.gravitee.am.management.handlers.management.api.JerseySpringTest)6 ApplicationOAuthSettings (io.gravitee.am.model.application.ApplicationOAuthSettings)6 Observable (io.reactivex.Observable)6 User (io.gravitee.am.identityprovider.api.User)5 ReferenceType (io.gravitee.am.model.ReferenceType)5 ApplicationScopeSettings (io.gravitee.am.model.application.ApplicationScopeSettings)5