Package com.openshift.client

Examples of com.openshift.client.IAuthorization


  }

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

        try {
        //read scope should not be allowed to create new authorizations
        IOpenShiftConnection connection =
            new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();
        connection.getUser().createAuthorization("shouldn't be allowed", IAuthorization.SCOPE_SESSION, 600);
        //should never get here
        assertTrue(false);
        } catch (OpenShiftEndpointException ex){
            assertThat(ex.getMessage(), StringContains.containsString("This action is not allowed with your current authorization"));
        }
  //clean up
  authorization.destroy();
      
    }
View Full Code Here


    }

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

        try {
            //userinfo scope should not be allowed to obtain SSH keys
      IOpenShiftConnection connection =
          new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();
      connection.getUser().getSSHKeys();
            //should never get here
            assertTrue(false);
        } catch (OpenShiftEndpointException ex){
            assertThat(ex.getMessage(), StringContains.containsString("This action is not allowed with your current authorization"));
        }
  //clean up
  authorization.destroy();
    }
View Full Code Here

    }

    @Test
    public void shouldCheckTokenExpiration() throws Exception {
        // pre-conditions
        IAuthorization authorization = user.createAuthorization("my note", IAuthorization.SCOPE_SESSION, 3);
        assertNotNull(authorization.getToken());
        assertEquals(authorization.getScopes(), IAuthorization.SCOPE_SESSION);
        //sleep for 5 seconds
        Thread.sleep(5000);

        try {
            //an expired token should fail getting user info
            IOpenShiftConnection connection =
                new TestConnectionBuilder().token(authorization.getToken()).disableSSLCertificateChecks().create();
            connection.getUser();
            //should never get here
            assertTrue(false);
        } catch (OpenShiftEndpointException ex){
            assertThat(ex.getMessage(), StringContains.containsString("Your credentials are not authorized to access"));
        }
  //clean up
  authorization.destroy();
    }
View Full Code Here

TOP

Related Classes of com.openshift.client.IAuthorization

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.