<commit_before>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.login;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.jasig.cas.web.support.WebConstants;

/**
 * 
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.0
 *
 */
public class LoginAsCredentialsAcceptorCompatibilityTests extends AbstractLoginCompatibilityTests {

    public LoginAsCredentialsAcceptorCompatibilityTests() throws IOException {
        super();
    }

    public LoginAsCredentialsAcceptorCompatibilityTests(String name) throws IOException {
        super(name);
    }
    
    public void testSingleSignOn() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        assertFormNotPresent();
    }
    
    public void testValidCredentialsAuthenticationWithWarn() throws UnsupportedEncodingException {
        final String service = "https://localhost:8443/contacts-cas/j_acegi_cas_security_check";
        beginAt("/login?service=" + URLEncoder.encode(service, "UTF-8"));
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        getDialog().getForm().setCheckbox("warn", true);
        submit();
//        checkCheckbox("warn");
        assertTextPresent(service);
        assertCookiePresent(WebConstants.COOKIE_PRIVACY);
        assertCookiePresent(WebConstants.COOKIE_TGC_ID);
    }

    public void testValidCredentialsAuthenticationWithoutWarn() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        // TODO testValidCredentialsAuthenticationWithoutWarn
    }
    
    public void testBadLoginTicket() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        setFormElement(WebConstants.LOGIN_TOKEN, "test");

        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
    
    public void testNoLoginTicket() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        setFormElement(WebConstants.LOGIN_TOKEN, "");
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
    

    
    public void testDoubleLoginTicket() {
        //TODO: covered by badLoginTicket?
    }
    
    public void testPassBadCredentials() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
    
    public void testPassEmptyCredentials() {
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }

}<commit_msg>Edited some tests<commit_after>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.login;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.jasig.cas.web.support.WebConstants;

/**
 * 
 * @author <NAME>
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.0
 *
 */
public class LoginAsCredentialsAcceptorCompatibilityTests extends AbstractLoginCompatibilityTests {

    public LoginAsCredentialsAcceptorCompatibilityTests() throws IOException {
        super();
    }

    public LoginAsCredentialsAcceptorCompatibilityTests(String name) throws IOException {
        super(name);
    }
    
    public void testSingleSignOn() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        assertCookiePresent(WebConstants.COOKIE_TGC_ID);
        assertFormNotPresent();
    }
    
    public void testValidCredentialsAuthenticationWithWarn() throws UnsupportedEncodingException {
        final String service = "https://localhost:8443/contacts-cas/j_acegi_cas_security_check";
        beginAt("/login?service=" + URLEncoder.encode(service, "UTF-8"));
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "test");
        getDialog().getForm().setCheckbox("warn", true);
        submit();
//        checkCheckbox("warn");
        assertTextPresent(service);
        assertCookiePresent(WebConstants.COOKIE_PRIVACY);
        assertCookiePresent(WebConstants.COOKIE_TGC_ID);
    }

    public void testValidCredentialsAuthenticationWithoutWarn() throws UnsupportedEncodingException {
    	final String service = "http://www.cnn.com";
        beginAt("/login?service=" + URLEncoder.encode(service, "UTF-8"));
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        // TODO testValidCredentialsAuthenticationWithoutWarn
    }
    
    /*
     * jWebUnit doesn't allow you to change pre-populated hidden form values.
     * 
    public void testBadLoginTicket() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        setFormElement(WebConstants.LOGIN_TOKEN, "test");

        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
    
    public void testNoLoginTicket() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        setFormElement(WebConstants.LOGIN_TOKEN, "");
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
        
    public void testDoubleLoginTicket() {
        //TODO: covered by badLoginTicket?
    }
     *
     */
    
    public void testPassBadCredentials() {
        setFormElement(FORM_USERNAME, "test");
        setFormElement(FORM_PASSWORD, "<PASSWORD>");
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }
    
    public void testPassEmptyCredentials() {
        submit();
        assertFormElementPresent(FORM_USERNAME);
    }

}
{'fraction_non_alphanumeric': 0.1068664580931994, 'fraction_numerical': 0.0037872550633953565, 'mean_word_length': 3.326210826210826, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3146226', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1705, 'n_words': 298}