// Path: src/main/java/no/asgari/civilization/server/dto/ForgotpassDTO.java
// @Data
// @JsonRootName(value = "forgotpassDTO")
// public class ForgotpassDTO {
//     @NotEmpty
//     @Email
//     private String email;
// 
//     @NotNull
//     private String newpassword;
// }
// 
// Path: src/main/java/no/asgari/civilization/server/model/Player.java
// @Data
// @JsonRootName("player")
// @NoArgsConstructor
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Player {
//     @JsonIgnore
//     public static final String COL_NAME = "player";
//     @JsonIgnore
//     public static final String USERNAME = "username";
//     @JsonIgnore
//     public static final String EMAIL = "email";
// 
//     @ObjectId
//     @Id
//     private String id;
// 
//     @NotBlank
//     //Unique
//     private String username;
// 
//     @Email
//     private String email;
// 
//     private boolean disableEmail = false;
// 
//     @NotBlank
//     private String password;
// 
//     private String newPassword;
// 
//     @JsonSerialize(using = LocalDateTimeSerializer.class)
//     @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//     private LocalDateTime emailSent;
// 
//     /**
//      * Set of unique active games This may be reduntant as it can be calculated by looping through all pbfs.players and finding match.
//      */
//     private Set<String> gameIds = new HashSet<>();
// 
//     @JsonIgnore
//     public Optional<LocalDateTime> getIfEmailSent() {
//         return Optional.ofNullable(emailSent);
//     }
// }
// 
// Path: src/test/java/no/asgari/civilization/server/mongodb/AbstractCivilizationTest.java
// public abstract class AbstractCivilizationTest {
// 
//     static {
//         LoggingFactory.bootstrap();
//     }
// 
//     @ClassRule
//     public static final DropwizardAppRule<CivilizationTestConfiguration> RULE = new DropwizardAppRule<>(CivilizationIntegrationTestApplication.class, "src/main/resources/config-test.yml");
// 
//     protected static CivilizationIntegrationTestApplication getApp() {
//         return RULE.getApplication();
//     }
// 
//     protected static String getUsernameAndPassEncoded() {
//         return "Basic " + B64Code.encode("cash1981" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static String getAdminEncoded() {
//         return "Basic " + B64Code.encode("admin" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static String getItchiEncoded() {
//         return "Basic " + B64Code.encode("Itchi" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static Client client() {
//         Client client = ClientBuilder.newClient();
//         client.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
//         return client;
//     }
// 
// }


import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Cleanup;
import no.asgari.civilization.server.dto.ForgotpassDTO;
import no.asgari.civilization.server.model.Player;
import no.asgari.civilization.server.mongodb.AbstractCivilizationTest;
import org.apache.commons.codec.digest.DigestUtils;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Test;
import org.mongojack.DBCursor;
import org.mongojack.DBQuery;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import java.util.Base64;
import static org.assertj.core.api.Assertions.assertThat;
    }

    @Test
    public void shouldLoginCorrectly() {
        Form form = new Form();
        form.param("username", "cash1981").param("password", "foo");

        Response response = client().target(BASE_URL + "/auth/login")
                .request()
                .post(Entity.form(form));

        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
    }

    @Test
    public void createExistingPlayer() throws JsonProcessingException {
        Player one = getApp().playerCollection.findOne();
        Form form = new Form();
        form.param("username", one.getUsername());
        form.param("password", one.getPassword());
        form.param("email", one.getEmail());

        Response response = client().target(
                UriBuilder.fromPath(BASE_URL + "/auth/register").build())
                .request()
                .post(Entity.form(form));

        assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400);
    }

// Path: src/main/java/no/asgari/civilization/server/dto/ForgotpassDTO.java
// @Data
// @JsonRootName(value = "forgotpassDTO")
// public class ForgotpassDTO {
//     @NotEmpty
//     @Email
//     private String email;
// 
//     @NotNull
//     private String newpassword;
// }
// 
// Path: src/main/java/no/asgari/civilization/server/model/Player.java
// @Data
// @JsonRootName("player")
// @NoArgsConstructor
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Player {
//     @JsonIgnore
//     public static final String COL_NAME = "player";
//     @JsonIgnore
//     public static final String USERNAME = "username";
//     @JsonIgnore
//     public static final String EMAIL = "email";
// 
//     @ObjectId
//     @Id
//     private String id;
// 
//     @NotBlank
//     //Unique
//     private String username;
// 
//     @Email
//     private String email;
// 
//     private boolean disableEmail = false;
// 
//     @NotBlank
//     private String password;
// 
//     private String newPassword;
// 
//     @JsonSerialize(using = LocalDateTimeSerializer.class)
//     @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//     private LocalDateTime emailSent;
// 
//     /**
//      * Set of unique active games This may be reduntant as it can be calculated by looping through all pbfs.players and finding match.
//      */
//     private Set<String> gameIds = new HashSet<>();
// 
//     @JsonIgnore
//     public Optional<LocalDateTime> getIfEmailSent() {
//         return Optional.ofNullable(emailSent);
//     }
// }
// 
// Path: src/test/java/no/asgari/civilization/server/mongodb/AbstractCivilizationTest.java
// public abstract class AbstractCivilizationTest {
// 
//     static {
//         LoggingFactory.bootstrap();
//     }
// 
//     @ClassRule
//     public static final DropwizardAppRule<CivilizationTestConfiguration> RULE = new DropwizardAppRule<>(CivilizationIntegrationTestApplication.class, "src/main/resources/config-test.yml");
// 
//     protected static CivilizationIntegrationTestApplication getApp() {
//         return RULE.getApplication();
//     }
// 
//     protected static String getUsernameAndPassEncoded() {
//         return "Basic " + B64Code.encode("cash1981" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static String getAdminEncoded() {
//         return "Basic " + B64Code.encode("admin" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static String getItchiEncoded() {
//         return "Basic " + B64Code.encode("Itchi" + ":" + "foo", StringUtil.__ISO_8859_1);
//     }
// 
//     protected static Client client() {
//         Client client = ClientBuilder.newClient();
//         client.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
//         return client;
//     }
// 
// }


// Path: src/test/java/no/asgari/civilization/server/resource/AuthResourceTest.java
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Cleanup;
import no.asgari.civilization.server.dto.ForgotpassDTO;
import no.asgari.civilization.server.model.Player;
import no.asgari.civilization.server.mongodb.AbstractCivilizationTest;
import org.apache.commons.codec.digest.DigestUtils;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Test;
import org.mongojack.DBCursor;
import org.mongojack.DBQuery;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import java.util.Base64;
import static org.assertj.core.api.Assertions.assertThat;

    }

    @Test
    public void shouldLoginCorrectly() {
        Form form = new Form();
        form.param("username", "cash1981").param("password", "foo");

        Response response = client().target(BASE_URL + "/auth/login")
                .request()
                .post(Entity.form(form));

        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
    }

    @Test
    public void createExistingPlayer() throws JsonProcessingException {
        Player one = getApp().playerCollection.findOne();
        Form form = new Form();
        form.param("username", one.getUsername());
        form.param("password", one.getPassword());
        form.param("email", one.getEmail());

        Response response = client().target(
                UriBuilder.fromPath(BASE_URL + "/auth/register").build())
                .request()
                .post(Entity.form(form));

        assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400);
    }

    @Test