package it.com.atlassian.stash;

import com.atlassian.webdriver.bitbucket.page.UserAccountPasswordPage;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class UserAccountPasswordTest extends BaseBrowserFuncTest {
    private static final String USERNAME = "accountDetailsTestUser";
    private static final String ORIG_PASSWORD = "original.password";
    private static final String NEW_PASSWORD = "new.password";

    @Test
    public void testUpdateDetails() {
        //Create the user that will be mutated during the test
        testContext.user(USERNAME, USERNAME, ORIG_PASSWORD, "test@test.com");

        UserAccountPasswordPage page = loginAs(USERNAME, ORIG_PASSWORD, UserAccountPasswordPage.class);
        page.setCurrentPassword(ORIG_PASSWORD);
        page.setNewPassword(NEW_PASSWORD);
        page.setConfirmNewPassword(NEW_PASSWORD);
        page = page.submit();

        assertEquals("Your password has been changed.", page.getMessageText());
    }
}
