Examples of IAuthorization


Examples of com.openshift.client.IAuthorization

    }

    @Override
    public boolean removeAuthorization(String id) {
        Assert.notNull(id);
        IAuthorization auth = getAuthorization(id);
        if (auth == null) {
            return false;
        }
        auth.destroy();
        api.removeAuthorization();
        //sets authorization list to null so next get/create will reload
        api.refresh();
        return true;
    }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateGenericAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.getAuthorization();
    assertNotNull(authorization.getToken());
    String token = authorization.getToken();
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).create();
    authorization = connection.getUser().getAuthorization();

    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertEquals(token, authorization.getToken());

    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_SESSION);
    assertNotNull(authorization.getToken());

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).create();
    authorization = connection.getUser().getAuthorization();

    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertEquals(authorization.getNote(), "my note");

    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateAuthorizationWithExpiration() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_SESSION, 600);
    assertNotNull(authorization.getToken());

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).create();
    authorization = connection.getUser().getAuthorization();

    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertEquals(authorization.getNote(), "my note");

    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldDestroyAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_READ, 600);
    assertNotNull(authorization.getToken());

    // operations
    authorization.destroy();

    // verification
    assertNull(authorization.getId());
    assertNull(authorization.getScopes());
    assertNull(authorization.getToken());
    assertNull(authorization.getNote());
    assertEquals(IAuthorization.NO_EXPIRES_IN, authorization.getExpiresIn());
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateNewAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_READ, 600);
    assertNotNull(authorization.getToken());

    // operations
    authorization.destroy();

    // verification
    // new authorization created upon #getAuthorization() since old one is destroyed
    IAuthorization newAuthorization = user.getAuthorization();
    assertFalse(authorization.equals(newAuthorization));
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }
 
  @Test
  public void shouldCreateGenericAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.getAuthorization();
    assertNotNull(authorization.getToken());
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();
    authorization = connection.getUser().getAuthorization();
   
    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);

    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_SESSION);
    assertNotNull(authorization.getToken());
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();
    authorization = connection.getUser().getAuthorization();

    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertEquals(authorization.getNote(), "my note");

    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldCreateAuthorizationWithExpiration() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_SESSION, 600);
    assertNotNull(authorization.getToken());
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);

    // operations
    IOpenShiftConnection connection =
        new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();

    authorization = connection.getUser().getAuthorization();

    // verifications
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertEquals(authorization.getNote(), "my note");
        //check for time remaining on the token now
        assertTrue((authorization.getExpiresIn() <= 600));
   
    authorization.destroy();
  }
View Full Code Here

Examples of com.openshift.client.IAuthorization

  }

  @Test
  public void shouldReplaceExistingAuthorization() throws Exception {
    // pre-conditions
    IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_READ, 600);
    assertNotNull(authorization.getToken());
    assertEquals(authorization.getScopes(), IAuthorization.SCOPE_READ);

    // operations
    user.createAuthorization("new note", IAuthorization.SCOPE_SESSION);
    IAuthorization newAuthorization = user.getAuthorization();
   
    // verifications
    assertFalse(authorization.equals(newAuthorization));
    assertEquals(newAuthorization.getScopes(), IAuthorization.SCOPE_SESSION);
    assertFalse(authorization.getToken().equals(newAuthorization.getToken()));
    assertEquals(newAuthorization.getNote(), "new note");
    assertTrue(newAuthorization.getExpiresIn() != 600);
   
    // cleanup
    authorization.destroy();
    newAuthorization.destroy();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.