Examples of IOpenShiftSSHKey


Examples of com.openshift.client.IOpenShiftSSHKey

    assertThat(sshKeys).isNotNull();
  }

  @Test
  public void shouldAddKey() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      ISSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);
      int numOfKeys = user.getSSHKeys().size();

      // operation
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, publicKey);

      // verifications
      assertThat(
          new SSHPublicKeyAssertion(key))
          .hasName(keyName)
          .hasPublicKey(publicKey.getPublicKey())
          .isType(publicKey.getKeyType());
      List<IOpenShiftSSHKey> keys = user.getSSHKeys();
      assertThat(keys.size()).isEqualTo(numOfKeys + 1);
      IOpenShiftSSHKey keyInList = SSHKeyTestUtils.getKey(keyName, keys);
      assertThat(key).isEqualTo(keyInList);
    } finally {
      SSHKeyTestUtils.silentlyDestroyKey(key);
    }
  }
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }

  @Test(expected=OpenShiftSSHKeyException.class)
  public void shouldNotAddKeyTwice() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      ISSHPublicKey publicKey = new SSHPublicKey(SSHKeyTestUtils.createDsaKeyPair());
      key = user.addSSHKey(keyName, publicKey);
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }
 
  @Test(expected=OpenShiftEndpointException.class)
  public void shouldNotPutKeyTwice() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      ISSHPublicKey publicKey = new SSHPublicKey(SSHKeyTestUtils.createDsaKeyPair());
      key = user.putSSHKey(keyName, publicKey);
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }
 
  @Test
  public void shouldUpdatePublicKey() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = createRandomTempFile().getAbsolutePath();
      String privateKeyPath = createRandomTempFile().getAbsolutePath();
      SSHKeyPair keyPair = SSHKeyPair.create(
          SSHKeyType.SSH_RSA,
          SSHKeyTestUtils.DEFAULT_PASSPHRASE,
          privateKeyPath,
          publicKeyPath);
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, keyPair);

      // operation
      String publicKey = SSHKeyPair.create(
          SSHKeyType.SSH_RSA,
          SSHKeyTestUtils.DEFAULT_PASSPHRASE,
          privateKeyPath,
          publicKeyPath).getPublicKey();
      key.setPublicKey(publicKey);

      // verification
      assertThat(key.getPublicKey()).isEqualTo(publicKey);
      IOpenShiftSSHKey openshiftKey = user.getSSHKeyByName(keyName);
      assertThat(
          new SSHPublicKeyAssertion(openshiftKey))
          .hasName(keyName)
          .hasPublicKey(publicKey)
          .isType(openshiftKey.getKeyType());
    } finally {
      SSHKeyTestUtils.silentlyDestroyKey(key);
    }

  }
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

  }

  @Test
  public void shouldReturnKeyForName() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      ISSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);

      // operation
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, publicKey);
      IOpenShiftSSHKey keyByName = user.getSSHKeyByName(keyName);

      // verifications
      assertThat(key).isEqualTo(keyByName);
    } finally {
      SSHKeyTestUtils.silentlyDestroyKey(key);
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }

  @Test
  public void shouldReturnKeyForPublicKey() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      ISSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);

      // operation
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, publicKey);
      IOpenShiftSSHKey keyByPublicKey = user.getSSHKeyByPublicKey(publicKey.getPublicKey());

      // verifications
      assertThat(key).isEqualTo(keyByPublicKey);
    } finally {
      SSHKeyTestUtils.silentlyDestroyKey(key);
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

  }

  @Test
  public void shouldUpdateKeyTypeAndPublicKey() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = createRandomTempFile().getAbsolutePath();
      String privateKeyPath = createRandomTempFile().getAbsolutePath();
      SSHKeyTestUtils.createDsaKeyPair(publicKeyPath, privateKeyPath);
      ISSHPublicKey publicKey = new SSHPublicKey(publicKeyPath);
      assertThat(publicKey.getKeyType()).isEqualTo(SSHKeyType.SSH_DSA);
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, publicKey);
      SSHKeyPair keyPair = SSHKeyPair.create(
          SSHKeyType.SSH_RSA, SSHKeyTestUtils.DEFAULT_PASSPHRASE, privateKeyPath, publicKeyPath);

      // operation
      key.setKeyType(SSHKeyType.SSH_RSA, keyPair.getPublicKey());

      // verification
      assertThat(key.getKeyType()).isEqualTo(SSHKeyType.SSH_RSA);
      assertThat(key.getPublicKey()).isEqualTo(keyPair.getPublicKey());
    } finally {
      SSHKeyTestUtils.silentlyDestroyKey(key);
    }
  }
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }

  @Test
  public void shouldDestroyKey() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, new SSHPublicKey(publicKeyPath));
     
      // operation
      key.destroy();
      key = null;
     
      // verification
      assertThat(user.getSSHKeyByName(keyName)).isNull();
    } finally {
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }
 
  @Test
  public void shouldRemoveKeyByName() throws Exception {
    IOpenShiftSSHKey key = null;
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      String keyName = SSHKeyTestUtils.createRandomKeyName();
      key = user.addSSHKey(keyName, new SSHPublicKey(publicKeyPath));
View Full Code Here

Examples of com.openshift.client.IOpenShiftSSHKey

    }
  }

  @Test
  public void shouldRefreshKeys() throws Exception {
    IOpenShiftSSHKey key = null;
    int originalNumOfKeys = user.getSSHKeys().size();
    try {
      // pre-conditions
      String publicKeyPath = SSHKeyTestUtils.createDsaKeyPair();
      IUser user = new TestConnectionBuilder().defaultCredentials().disableSSLCertificateChecks().create().getUser();
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.