Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.ResourceServer


  @Test
  public void test() {
    ResourceServerRepository repo = getRepository(ResourceServerRepository.class);
    ClientRepository clientRepo = getRepository(ClientRepository.class);

    ResourceServer rs = repo.findByKey("authorization-server-admin");
    Client client = null;
    assertFalse(rs.containsClient(client));

    client = clientRepo.findByClientId("authorization-server-admin-js-client");
    assertTrue(rs.containsClient(client));
    Set<Client> clients = rs.getClients();
    assertEquals(1, clients.size());
  }
View Full Code Here


    ClientRepository clientRepo = getRepository(ClientRepository.class);

    getEntityManager().getTransaction().begin();

    // Create and save a resourceServer
    ResourceServer resourceServer = new ResourceServer();
    resourceServer.setKey("key");
    resourceServer.setName("name");
    resourceServer.setSecret("sec");
    resourceServer.setContactName("contact");
    resourceServer.setScopes(Arrays.asList("read"));
    resourceServer = repo.save(resourceServer);

    // Create and save a client, associated with the resourceServer
    Client c = new Client();
    c.setName("name");
    c.setClientId("clientid");
    c.setSecret(UUID.randomUUID().toString());
    c.setResourceServer(resourceServer);
    resourceServer.setClients(new HashSet(Arrays.asList(c)));
    c = clientRepo.save(c);
    getEntityManager().getTransaction().commit();

    // See that the client can be found
    assertNotNull(clientRepo.findOne(c.getId()));

    long resourceServerId = resourceServer.getId();
    // Remove the resourceServer
    getEntityManager().getTransaction().begin();
    repo.delete(resourceServer);
    getEntityManager().getTransaction().commit();
View Full Code Here

    webResource = com.sun.jersey.api.client.Client.create(config)
        .resource(baseUrl())
        .path("admin")
        .path("resourceServer");

    ResourceServer newResourceServer = new ResourceServer();
    newResourceServer.setContactName("myContactName");
    newResourceServer.setDescription("The description");
    newResourceServer.setName("the name" + System.currentTimeMillis());
    newResourceServer.setKey("the-key-" + System.currentTimeMillis());
    newResourceServer.setThumbNailUrl("http://example.com/thumbnail");
    newResourceServer.setScopes(resourceServerScopes);

    resourceServer = webResource
        .type(MediaType.APPLICATION_JSON)
        .header("Authorization", authorizationBearer(ACCESS_TOKEN))
        .put(ResourceServer.class, newResourceServer);
View Full Code Here

    ResourceServerRepository resourceServerRepository = getRepository(ResourceServerRepository.class);
    AccessTokenRepository accessTokenRepository = getRepository(AccessTokenRepository.class);
    AuthorizationRequestRepository authorizationRequestRepository = getRepository(AuthorizationRequestRepository.class);

    // Create and save a resource Server
    ResourceServer r = new ResourceServer();
    r.setKey("key");
    r.setName("name");
    r.setContactName("contactname");
    r.setSecret("secret");

    r = resourceServerRepository.save(r);

    // Create and save a client
    Client client = new Client();
    client.setName("name");
    client.setClientId("clientid");

    // Let them meet each other
    r.setClients(new HashSet(Arrays.asList(client)));
    client.setResourceServer(r);

    client = repo.save(client);

View Full Code Here

    webResource = Client.create(config).resource(baseUrl()).path("admin").path("resourceServer");
  }

  @Test
  public void put() {
    ResourceServer resourceServer = buildResourceServer();

    final ClientResponse response = webResource.header("Authorization", authorizationBearer(ACCESS_TOKEN)).put(ClientResponse.class,
        resourceServer);

    assertEquals(201, response.getStatus());
    ResourceServer returnedResourceServer = response.getEntity(ResourceServer.class);
    assertEquals(resourceServer.getName(), returnedResourceServer.getName());
    assertNotNull("the server should generate an ID", returnedResourceServer.getId());
    assertNotNull("the server should generate a secret", returnedResourceServer.getSecret());
  }
View Full Code Here

    assertNotNull("the server should generate a secret", returnedResourceServer.getSecret());
  }

  @Test
  public void putInvalid() {
    ResourceServer resourceServer = buildResourceServer();

    final ClientResponse response = webResource.header("Authorization", authorizationBearer(ACCESS_TOKEN)).put(ClientResponse.class,
        resourceServer);

    assertEquals(201, response.getStatus());
View Full Code Here

    // First get a non existing resource server
    ClientResponse response = webResource.path("-1").header("Authorization", authorizationBearer(ACCESS_TOKEN)).get(ClientResponse.class);
    assertEquals("Random id should return nothing", 404, response.getStatus());

    // Insert some random one.
    ResourceServer existingResourceServer = putSomeResourceServer();

    // Get it again.
    final ResourceServer returnedFromGet = webResource.path(String.valueOf(existingResourceServer.getId()))
        .header("Authorization", authorizationBearer(ACCESS_TOKEN)).get(ResourceServer.class);
    assertEquals(existingResourceServer, returnedFromGet);

    // Get all
    final List<ResourceServer> returnFromGetAll = webResource.header("Authorization", authorizationBearer(ACCESS_TOKEN)).get(
View Full Code Here

  }

  @Test
  public void post() {

    ResourceServer existingResourceServer = putSomeResourceServer();

    final String newThumbnailUrl = "http://example.com/anotherThumbNailUrl";
    existingResourceServer.setThumbNailUrl(newThumbnailUrl);

    ResourceServer returnedFromPost = webResource.path(String.valueOf(existingResourceServer.getId()))
        .header("Authorization", authorizationBearer(ACCESS_TOKEN)).post(ResourceServer.class, existingResourceServer);

    assertEquals(newThumbnailUrl, returnedFromPost.getThumbNailUrl());
  }
View Full Code Here

  @Test
  public void delete() {

    // create a random resourceServer
    ResourceServer existingResourceServer = putSomeResourceServer();

    // Delete it again.
    String id = String.valueOf(existingResourceServer.getId());
    ClientResponse response = webResource.path(id).header("Authorization", authorizationBearer(ACCESS_TOKEN)).delete(ClientResponse.class);

    // Make sure that the response is a 'no content' one
    assertEquals(204, response.getStatus());
View Full Code Here

   * Convenience method to put some random resourceServer.
   *
   * @return a persisted resourceServer
   */
  private ResourceServer putSomeResourceServer() {
    ResourceServer resourceServer = buildResourceServer();

    return webResource.header("Authorization", authorizationBearer(ACCESS_TOKEN)).put(ResourceServer.class, resourceServer);
  }
View Full Code Here

TOP

Related Classes of org.surfnet.oaaas.model.ResourceServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.