# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient

def test_create_certificate():
    client = WindmillTestClient(__name__)

    client.open(url=u'http://127.0.0.1:8000/admin/logout/')
    client.waits.forPageLoad(timeout=u'8000')
    client.open(url=u'http://127.0.0.1:8000/admin/')
    client.waits.forPageLoad(timeout=u'8000')
    client.waits.forElement(timeout=u'8000', id=u'id_username')
    client.click(id=u'id_username')
    client.type(text=u'admin', id=u'id_username')
    client.type(text=u'admin', id=u'id_password')
    client.click(value=u'Log in')
    client.waits.forPageLoad(timeout=u'20000')
    client.waits.forElement(link=u'Certificates', timeout=u'8000')
    client.click(link=u'Certificates')
    client.waits.forPageLoad(timeout=u'20000')
    client.waits.forElement(link=u'              Add certificate             ', timeout=u'8000')
    client.click(link=u'              Add certificate             ')
    client.waits.forPageLoad(timeout=u'20000')
    client.waits.forElement(timeout=u'8000', id=u'id_description')
    client.click(id=u'id_description')
    client.type(text=u'srv1', id=u'id_description')
    client.type(text=u'srv1.mycompany.com', id=u'id_common_name')
    client.click(id=u'id_state')
    client.type(text=u'Bavaria', id=u'id_state')
    client.type(text=u'Munich', id=u'id_locality')
    client.type(text=u'My Company', id=u'id_organization')
    client.type(text=u'Datacenter', id=u'id_OU')
    client.click(id=u'id_email')
    client.type(text=u'a@b.com', id=u'id_email')
    client.click(id=u'id_subjaltname')
    client.type(text=u'DNS:*.mycompany.com', id=u'id_subjaltname')
    client.click(id=u'id_key_length')
    client.select(option=u'', id=u'id_key_length')
    client.click(value=u'1024')
    client.click(id=u'id_cert_extension')
    client.select(option=u'', id=u'id_cert_extension')
    client.click(value=u'v3_server_cert')
    client.click(id=u'id_valid_days')
    client.type(text=u'365', id=u'id_valid_days')
    client.click(id=u'id_parent')
    client.select(option=u'', id=u'id_parent')
    client.click(value=u'2')
    client.click(id=u'id_parent_passphrase')
    client.type(text=u'1234567890', id=u'id_parent_passphrase')
    client.click(xpath=u"//form[@id='certificate_form']/div[2]/div[2]/input[1]")
    client.waits.forPageLoad(timeout=u'20000')
    client.asserts.assertTextIn(xpath=u"//div[@id='container']/ul/li", validator=u'The certificate "srv1.mycompany.com" was added successfully.')
