// Path: provider/src/main/java/com/cloudera/director/aws/STSAssumeNRolesSessionCredentialsProvider.java
// static public class RoleConfiguration {
//   private final String roleArn;
//   private final String roleSessionName;
//   private final String roleExternalId;
// 
//   /**
//    * Creates an instance of role configuration.
//    *
//    * @param roleArn         role Arn
//    * @param roleSessionName role session name
//    */
//   public RoleConfiguration(String roleArn, String roleSessionName) {
//     this(roleArn, roleSessionName, null);
//   }
// 
//   /**
//    * Creates an instance of role configuration.
//    *
//    * @param roleArn         role Arn
//    * @param roleSessionName role session name
//    * @param roleExternalId  role external Id
//    */
//   public RoleConfiguration(String roleArn, String roleSessionName, String roleExternalId) {
//     checkArgument(!isEmpty(roleArn), "roleArn is empty");
//     checkArgument(!isEmpty(roleSessionName), "roleSessionName is empty");
// 
//     this.roleArn = roleArn;
//     this.roleSessionName = roleSessionName;
//     this.roleExternalId = roleExternalId;
//   }
// 
//   /**
//    * Gets role session name.
//    *
//    * @return role session name
//    */
//   public String getRoleSessionName() {
//     return roleSessionName;
//   }
// 
//   /**
//    * Gets role external Id.
//    *
//    * @return role external Id
//    */
//   public String getRoleExternalId() {
//     return roleExternalId;
//   }
// 
//   /**
//    * Gets role Arn.
//    *
//    * @return role Arn
//    */
//   public String getRoleArn() {
//     return roleArn;
//   }
// 
//   @Override
//   public String toString() {
//     return "RoleConfiguration{" +
//         "roleArn='" + roleArn + '\'' +
//         ", roleSessionName='" + roleSessionName + '\'' +
//         ", roleExternalId='" + roleExternalId + '\'' +
//         '}';
//   }
// }


import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
import com.cloudera.director.aws.STSAssumeNRolesSessionCredentialsProvider.RoleConfiguration;
import com.cloudera.director.aws.shaded.com.typesafe.config.Config;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigFactory;
import com.google.common.base.Function;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import org.junit.Rule;
// (c) Copyright 2017 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.aws;





public class STSRolesTest {
  private static final String ROLE = "roleSwitch";
  private static final String ROLE_ARN = "arn:aws:iam::123456789012:role/" + ROLE;
  private static final String QUOTED_ROLE_ARN = "\"" + ROLE_ARN + "\"";
  private static final String ROLE_SESSION_NAME = "reader";
  private static final String ROLE_EXTERNAL_ID = "token";

  @Rule
  public TemporaryFolder TEMPORARY_FOLDER = new TemporaryFolder();

  @Test
  public void testParseConfigWithArnSessionNameAndExternalId() throws IOException {
    Function<PrintWriter, Void> writer = new Function<PrintWriter, Void>() {
      @Override
      public Void apply(PrintWriter printWriter) {
        printWriter.println("  {");
        printWriter.println("    " + STSRoles.ROLE_ARN + ": " + QUOTED_ROLE_ARN);
        printWriter.println("    " + STSRoles.ROLE_SESSION_NAME + ": " + ROLE_SESSION_NAME);
        printWriter.println("    " + STSRoles.ROLE_EXTERNAL_ID + ": " + ROLE_EXTERNAL_ID);
        printWriter.println("  }");
        return null;
      }
    };

    Function<STSRoles, Void> assertions = new Function<STSRoles, Void>() {
      @Override
      public Void apply(STSRoles stsRoles) {
        assertThat(stsRoles.getRoleConfigurations()).isNotNull();
        assertThat(stsRoles.getRoleConfigurations().size()).isEqualTo(1);

// Path: provider/src/main/java/com/cloudera/director/aws/STSAssumeNRolesSessionCredentialsProvider.java
// static public class RoleConfiguration {
//   private final String roleArn;
//   private final String roleSessionName;
//   private final String roleExternalId;
// 
//   /**
//    * Creates an instance of role configuration.
//    *
//    * @param roleArn         role Arn
//    * @param roleSessionName role session name
//    */
//   public RoleConfiguration(String roleArn, String roleSessionName) {
//     this(roleArn, roleSessionName, null);
//   }
// 
//   /**
//    * Creates an instance of role configuration.
//    *
//    * @param roleArn         role Arn
//    * @param roleSessionName role session name
//    * @param roleExternalId  role external Id
//    */
//   public RoleConfiguration(String roleArn, String roleSessionName, String roleExternalId) {
//     checkArgument(!isEmpty(roleArn), "roleArn is empty");
//     checkArgument(!isEmpty(roleSessionName), "roleSessionName is empty");
// 
//     this.roleArn = roleArn;
//     this.roleSessionName = roleSessionName;
//     this.roleExternalId = roleExternalId;
//   }
// 
//   /**
//    * Gets role session name.
//    *
//    * @return role session name
//    */
//   public String getRoleSessionName() {
//     return roleSessionName;
//   }
// 
//   /**
//    * Gets role external Id.
//    *
//    * @return role external Id
//    */
//   public String getRoleExternalId() {
//     return roleExternalId;
//   }
// 
//   /**
//    * Gets role Arn.
//    *
//    * @return role Arn
//    */
//   public String getRoleArn() {
//     return roleArn;
//   }
// 
//   @Override
//   public String toString() {
//     return "RoleConfiguration{" +
//         "roleArn='" + roleArn + '\'' +
//         ", roleSessionName='" + roleSessionName + '\'' +
//         ", roleExternalId='" + roleExternalId + '\'' +
//         '}';
//   }
// }


// Path: tests/src/test/java/com/cloudera/director/aws/STSRolesTest.java
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
import com.cloudera.director.aws.STSAssumeNRolesSessionCredentialsProvider.RoleConfiguration;
import com.cloudera.director.aws.shaded.com.typesafe.config.Config;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigFactory;
import com.google.common.base.Function;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import org.junit.Rule;

// (c) Copyright 2017 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.aws;





public class STSRolesTest {
  private static final String ROLE = "roleSwitch";
  private static final String ROLE_ARN = "arn:aws:iam::123456789012:role/" + ROLE;
  private static final String QUOTED_ROLE_ARN = "\"" + ROLE_ARN + "\"";
  private static final String ROLE_SESSION_NAME = "reader";
  private static final String ROLE_EXTERNAL_ID = "token";

  @Rule
  public TemporaryFolder TEMPORARY_FOLDER = new TemporaryFolder();

  @Test
  public void testParseConfigWithArnSessionNameAndExternalId() throws IOException {
    Function<PrintWriter, Void> writer = new Function<PrintWriter, Void>() {
      @Override
      public Void apply(PrintWriter printWriter) {
        printWriter.println("  {");
        printWriter.println("    " + STSRoles.ROLE_ARN + ": " + QUOTED_ROLE_ARN);
        printWriter.println("    " + STSRoles.ROLE_SESSION_NAME + ": " + ROLE_SESSION_NAME);
        printWriter.println("    " + STSRoles.ROLE_EXTERNAL_ID + ": " + ROLE_EXTERNAL_ID);
        printWriter.println("  }");
        return null;
      }
    };

    Function<STSRoles, Void> assertions = new Function<STSRoles, Void>() {
      @Override
      public Void apply(STSRoles stsRoles) {
        assertThat(stsRoles.getRoleConfigurations()).isNotNull();
        assertThat(stsRoles.getRoleConfigurations().size()).isEqualTo(1);

        RoleConfiguration roleConfiguration = stsRoles.getRoleConfigurations().get(0);