// Path: e2e/src/test/java/com/thoughtworks/go/TestHelpers.java
// public class TestHelpers {
// 
//     @SneakyThrows
//     public void enableAuth() {
//         executeHelper("enable-auth.py");
//     }
// 
//     @SneakyThrows
//     public void disableAuth() {
//         executeHelper("disable-auth.py");
//     }
// 
//     @SneakyThrows
//     public void clearAuthFile() {
//         executeHelper("clear-password-file.py");
//     }
// 
//     @SneakyThrows
//     public void executeHelper(String helperName, String... params) {
//         List<String> command = Lists.newArrayList(format("/tmp/test-helpers/%s", helperName));
//         command.addAll(asList(params));
//         executeDockerCommand(command);
//     }
// 
//     @SneakyThrows
//     private void executeDockerCommand(List<String> commands) {
//         List<String> commandList = Lists.newArrayList("./bin/execute-docker-command.sh");
//         commandList.addAll(commands);
//         int response = new ProcessBuilder().command(commandList).inheritIO().start().waitFor();
//         if (response != 0) {
//             throw new RuntimeException(format("Failed to execute %s", commandList.toString()));
//         }
//     }
// 
//     public void createPBKDF2PasswordEntryFor(String username, String password) {
//         int iterations = 10000;
//         int keyLength = 256;
//         byte[] salt = createSalt();
//         String saltString = Base64.encodeBase64String(salt);
//         String hash = createHash(salt, password, iterations, keyLength);
//         String entry = format("%s:%s:%s:%s(%s, %s)", username, hash, saltString, "PBKDF2WithHmacSHA1", String.valueOf(iterations), String.valueOf(keyLength));
//         executeHelper("insert-password-entry.py", entry);
//     }
// 
//     public void createBCryptPasswordEntryFor(String username, String password) {
//         String saltString = BCrypt.gensalt();
//         String hash = BCrypt.hashpw(password, saltString);
//         String entry = format("%s:%s::%s", username, hash, "bcrypt");
//         executeHelper("insert-password-entry.py", entry);
//     }
// 
//     @SneakyThrows
//     private String createHash(byte[] salt, String password, int iterations, int keyLength) {
//         PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, iterations, keyLength);
//         byte[] key = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1").generateSecret(spec).getEncoded();
//         return Hex.encodeHexString(key);
//     }
// 
//     private byte[] createSalt() {
//         byte[] salt = new byte[16];
//         new SecureRandom().nextBytes(salt);
//         return salt;
//     }
// }


import com.thoughtworks.go.TestHelpers;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HttpContext;
import java.io.IOException;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.thoughtworks.go.strongauth.glue;




public class StrongAuthGlue {

    private HttpResponse response;
// Path: e2e/src/test/java/com/thoughtworks/go/TestHelpers.java
// public class TestHelpers {
// 
//     @SneakyThrows
//     public void enableAuth() {
//         executeHelper("enable-auth.py");
//     }
// 
//     @SneakyThrows
//     public void disableAuth() {
//         executeHelper("disable-auth.py");
//     }
// 
//     @SneakyThrows
//     public void clearAuthFile() {
//         executeHelper("clear-password-file.py");
//     }
// 
//     @SneakyThrows
//     public void executeHelper(String helperName, String... params) {
//         List<String> command = Lists.newArrayList(format("/tmp/test-helpers/%s", helperName));
//         command.addAll(asList(params));
//         executeDockerCommand(command);
//     }
// 
//     @SneakyThrows
//     private void executeDockerCommand(List<String> commands) {
//         List<String> commandList = Lists.newArrayList("./bin/execute-docker-command.sh");
//         commandList.addAll(commands);
//         int response = new ProcessBuilder().command(commandList).inheritIO().start().waitFor();
//         if (response != 0) {
//             throw new RuntimeException(format("Failed to execute %s", commandList.toString()));
//         }
//     }
// 
//     public void createPBKDF2PasswordEntryFor(String username, String password) {
//         int iterations = 10000;
//         int keyLength = 256;
//         byte[] salt = createSalt();
//         String saltString = Base64.encodeBase64String(salt);
//         String hash = createHash(salt, password, iterations, keyLength);
//         String entry = format("%s:%s:%s:%s(%s, %s)", username, hash, saltString, "PBKDF2WithHmacSHA1", String.valueOf(iterations), String.valueOf(keyLength));
//         executeHelper("insert-password-entry.py", entry);
//     }
// 
//     public void createBCryptPasswordEntryFor(String username, String password) {
//         String saltString = BCrypt.gensalt();
//         String hash = BCrypt.hashpw(password, saltString);
//         String entry = format("%s:%s::%s", username, hash, "bcrypt");
//         executeHelper("insert-password-entry.py", entry);
//     }
// 
//     @SneakyThrows
//     private String createHash(byte[] salt, String password, int iterations, int keyLength) {
//         PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, iterations, keyLength);
//         byte[] key = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1").generateSecret(spec).getEncoded();
//         return Hex.encodeHexString(key);
//     }
// 
//     private byte[] createSalt() {
//         byte[] salt = new byte[16];
//         new SecureRandom().nextBytes(salt);
//         return salt;
//     }
// }


// Path: e2e/src/test/java/com/thoughtworks/go/strongauth/glue/StrongAuthGlue.java
import com.thoughtworks.go.TestHelpers;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HttpContext;
import java.io.IOException;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;

package com.thoughtworks.go.strongauth.glue;




public class StrongAuthGlue {

    private HttpResponse response;
    private TestHelpers testHelpers = new TestHelpers();