diff --git a/awx/ui/test/e2e/.eslintrc.js b/awx/ui/test/e2e/.eslintrc.js index 7ce4f5483c..02959f42e3 100644 --- a/awx/ui/test/e2e/.eslintrc.js +++ b/awx/ui/test/e2e/.eslintrc.js @@ -1,5 +1,6 @@ module.exports = { rules: { - 'no-unused-expressions': 'off' + 'no-unused-expressions': 'off', + 'no-unused-vars': 'off', } }; diff --git a/awx/ui/test/e2e/objects/credentials.js b/awx/ui/test/e2e/objects/credentials.js index ed825d9426..ad3cd3bb91 100644 --- a/awx/ui/test/e2e/objects/credentials.js +++ b/awx/ui/test/e2e/objects/credentials.js @@ -67,6 +67,7 @@ const gce = createFormSection({ email: 'Service Account Email Address', project: 'Project', sshKeyData: 'RSA Private Key', + serviceAccountFile: 'Service Account JSON File' } }); diff --git a/awx/ui/test/e2e/objects/sections/createFormSection.js b/awx/ui/test/e2e/objects/sections/createFormSection.js index 3a8ebb810b..97e4b73394 100644 --- a/awx/ui/test/e2e/objects/sections/createFormSection.js +++ b/awx/ui/test/e2e/objects/sections/createFormSection.js @@ -12,7 +12,7 @@ const inputContainerElements = { popover: '.at-Popover-container', yaml: 'input[type="radio", value="yaml"]', json: 'input[type="radio", value="json"]', - revert: 'a[class~="reset"]', + reset: 'a[class~="reset"]', down: 'span[class^="fa-angle-down"]', up: 'span[class^="fa-angle-up"]', prompt: { @@ -34,6 +34,14 @@ const inputContainerElements = { off: { locateStrategy: 'xpath', selector: `.//button[${normalized}='off']` + }, + replace: { + locateStrategy: 'xpath', + selector: `.//button[${normalized}='replace']` + }, + revert: { + locateStrategy: 'xpath', + selector: `.//button[${normalized}='revert']` } }; diff --git a/awx/ui/test/e2e/tests/gce.alt.json b/awx/ui/test/e2e/tests/gce.alt.json new file mode 100644 index 0000000000..1080223f07 --- /dev/null +++ b/awx/ui/test/e2e/tests/gce.alt.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "test321", + "private_key_id": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "private_key": "-----BEGIN PRIVATE KEY-----\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBB\n-----END PRIVATE KEY-----\n", + "client_email": "test321.iam.gserviceaccount.com", + "client_id": "321987654321987654321", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://accounts.google.com/o/oauth2/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test321%40test.iam.gserviceaccount.com" +} diff --git a/awx/ui/test/e2e/tests/gce.invalid.json b/awx/ui/test/e2e/tests/gce.invalid.json new file mode 100644 index 0000000000..9977a2836c --- /dev/null +++ b/awx/ui/test/e2e/tests/gce.invalid.json @@ -0,0 +1 @@ +invalid diff --git a/awx/ui/test/e2e/tests/gce.json b/awx/ui/test/e2e/tests/gce.json new file mode 100644 index 0000000000..dd3055f059 --- /dev/null +++ b/awx/ui/test/e2e/tests/gce.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "test123", + "private_key_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "private_key": "-----BEGIN PRIVATE KEY-----\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAA\n-----END PRIVATE KEY-----\n", + "client_email": "test123.iam.gserviceaccount.com", + "client_id": "123456789123456789123", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://accounts.google.com/o/oauth2/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test123%40test.iam.gserviceaccount.com" +} diff --git a/awx/ui/test/e2e/tests/gce.missing.json b/awx/ui/test/e2e/tests/gce.missing.json new file mode 100644 index 0000000000..5d0d1e2968 --- /dev/null +++ b/awx/ui/test/e2e/tests/gce.missing.json @@ -0,0 +1,11 @@ +{ + "type": "service_account", + "project_id": "test654", + "private_key_id": "cccccccccccccccccccccccccccccccccccccccc", + "private_key": "-----BEGIN PRIVATE KEY-----\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nCCCCCCCCCCCCCCCCCCCCCCCC\n-----END PRIVATE KEY-----\n", + "client_id": "654321987654321987654", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://accounts.google.com/o/oauth2/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test654%40test.iam.gserviceaccount.com" +} diff --git a/awx/ui/test/e2e/tests/test-credentials-add-edit-gce-file.js b/awx/ui/test/e2e/tests/test-credentials-add-edit-gce-file.js new file mode 100644 index 0000000000..458b735630 --- /dev/null +++ b/awx/ui/test/e2e/tests/test-credentials-add-edit-gce-file.js @@ -0,0 +1,269 @@ +import path from 'path'; +import uuid from 'uuid'; + +const GCE_SERVICE_ACCOUNT_FILE = path.resolve(__dirname, 'gce.json'); +const GCE_SERVICE_ACCOUNT_FILE_ALT = path.resolve(__dirname, 'gce.alt.json'); +const GCE_SERVICE_ACCOUNT_FILE_INVALID = path.resolve(__dirname, 'gce.invalid.json'); +const GCE_SERVICE_ACCOUNT_FILE_MISSING = path.resolve(__dirname, 'gce.missing.json'); + +let credentials; + +module.exports = { + before: (client, done) => { + credentials = client.page.credentials(); + + client.login(); + client.waitForAngular(); + + credentials.section.navigation + .waitForElementVisible('@credentials') + .click('@credentials'); + + credentials + .waitForElementVisible('div.spinny') + .waitForElementNotVisible('div.spinny'); + + credentials.section.list + .waitForElementVisible('@add') + .click('@add'); + + credentials.section.add.section.details + .waitForElementVisible('@save') + .setValue('@name', `credential-${uuid().substr(0, 8)}`) + .setValue('@type', 'Google Compute Engine', done); + }, + 'expected fields are initially visible and enabled': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + details.expect.element('@name').visible; + details.expect.element('@description').visible; + details.expect.element('@organization').visible; + details.expect.element('@type').visible; + + gce.expect.element('@email').visible; + gce.expect.element('@sshKeyData').visible; + gce.expect.element('@project').visible; + gce.expect.element('@serviceAccountFile').visible; + + details.expect.element('@name').enabled; + details.expect.element('@description').enabled; + details.expect.element('@organization').enabled; + details.expect.element('@type').enabled; + + gce.expect.element('@email').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').not.present; + }, + 'select valid credential file': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE); + + gce.expect.element('@email').not.enabled; + gce.expect.element('@sshKeyData').not.enabled; + gce.expect.element('@project').not.enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').not.present; + }, + 'deselect valid credential file': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.click('form i[class*="trash"]'); + + gce.expect.element('@email').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').not.present; + + gce.section.email.expect.element('@error').visible; + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + }, + 'select credential file with missing field': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_MISSING); + + gce.expect.element('@email').not.enabled; + gce.expect.element('@sshKeyData').not.enabled; + gce.expect.element('@project').not.enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').not.present; + + gce.section.email.expect.element('@error').visible; + + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + gce.section.sshKeyData.expect.element('@error').not.present; + }, + 'deselect credential file with missing field': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.click('form i[class*="trash"]'); + + gce.expect.element('@email').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').not.present; + + gce.section.email.expect.element('@error').visible; + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + }, + 'select invalid credential file': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_INVALID); + + gce.expect.element('@email').not.enabled; + gce.expect.element('@sshKeyData').not.enabled; + gce.expect.element('@project').not.enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').not.present; + + gce.section.email.expect.element('@error').visible; + gce.section.serviceAccountFile.expect.element('@error').visible; + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.project.expect.element('@error').not.present; + }, + 'deselect invalid credential file': client => { + const { details } = credentials.section.add.section; + const { gce } = details.section; + + gce.section.serviceAccountFile.click('form i[class*="trash"]'); + + gce.expect.element('@email').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').visible; + gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').enabled; + gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').not.present; + + gce.section.email.expect.element('@error').visible; + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + }, + 'save valid credential file': client => { + const add = credentials.section.add.section.details; + const edit = credentials.section.edit.section.details; + + add.section.gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE); + + add.section.gce.expect.element('@email').not.enabled; + add.section.gce.expect.element('@sshKeyData').not.enabled; + add.section.gce.expect.element('@project').not.enabled; + add.section.gce.expect.element('@serviceAccountFile').enabled; + + add.section.gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').visible; + add.section.gce.section.serviceAccountFile.expect.element('form i[class*="trash"]').enabled; + add.section.gce.section.serviceAccountFile.expect.element('form i[class*="folder"]').not.present; + + add.click('@save'); + + credentials + .waitForElementVisible('div.spinny') + .waitForElementNotVisible('div.spinny'); + + edit.section.gce.expect.element('@email').enabled; + edit.section.gce.expect.element('@project').enabled; + + edit.section.gce.expect.element('@serviceAccountFile').not.enabled; + edit.section.gce.expect.element('@sshKeyData').not.enabled; + }, + 'select and deselect credential file when replacing private key': client => { + const { gce } = credentials.section.edit.section.details.section; + + gce.section.sshKeyData.waitForElementVisible('@replace'); + gce.section.sshKeyData.click('@replace'); + + gce.expect.element('@email').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.email.expect.element('@error').not.present; + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + + gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_ALT); + + gce.expect.element('@serviceAccountFile').enabled; + + gce.expect.element('@email').not.enabled; + gce.expect.element('@sshKeyData').not.enabled; + gce.expect.element('@project').not.enabled; + + gce.section.email.expect.element('@error').not.present; + gce.section.project.expect.element('@error').not.present; + gce.section.sshKeyData.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + + gce.section.sshKeyData.expect.element('@replace').not.present; + gce.section.sshKeyData.expect.element('@revert').present; + gce.section.sshKeyData.expect.element('@revert').not.enabled; + + gce.section.serviceAccountFile.click('form i[class*="trash"]'); + + gce.expect.element('@email').enabled; + gce.expect.element('@sshKeyData').enabled; + gce.expect.element('@project').enabled; + gce.expect.element('@serviceAccountFile').enabled; + + gce.section.sshKeyData.expect.element('@error').visible; + + gce.section.email.expect.element('@error').not.present; + gce.section.project.expect.element('@error').not.present; + gce.section.serviceAccountFile.expect.element('@error').not.present; + + gce.section.sshKeyData.expect.element('@revert').enabled; + + gce.section.sshKeyData.click('@revert'); + + gce.expect.element('@email').enabled; + gce.expect.element('@project').enabled; + + gce.expect.element('@serviceAccountFile').not.enabled; + gce.expect.element('@sshKeyData').not.enabled; + + client.end(); + } +};