Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add frontend e2e test (smoke test for ssl) #1096

Merged
merged 13 commits into from
Dec 26, 2020
6 changes: 6 additions & 0 deletions web/cypress/fixtures/certificate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"matchCert": "-----BEGIN CERTIFICATE-----\nMIIENzCCAx+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCQ04x\nEjAQBgNVBAgMCUd1YW5nZG9uZzESMBAGA1UEBwwJR3Vhbmd6aG91MRQwEgYDVQQK\nDAtGaXNoZHJvd25lZDEcMBoGA1UEAwwTRmlzaGRyb3duZWQgUk9PVCBDQTAeFw0y\nMDExMDYwOTQ3NDhaFw0yMjExMDYwOTQ3NDhaMH8xCzAJBgNVBAYTAkNOMRIwEAYD\nVQQIDAlHdWFuZ2RvbmcxEjAQBgNVBAcMCUd1YW5nemhvdTEUMBIGA1UECgwLRmlz\naGRyb3duZWQxFzAVBgNVBAsMDnd3dy50ZXN0aGouY29tMRkwFwYDVQQDDBAqLnd3\ndy50ZXN0aGouY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzt2V\nU3JAtNkiUhC/FKA0D3z9gRHaNR2+JYqnMHbetXJXF0ohWMKzjmzauaMYXUDPfQ8y\nc7leR6Gj9Ow5A0sUwlSdH1P0viM1gnQj0kLxeb59vQaWSNuPm73C26R6en/Jgu8I\n09c+gsBkhNykcnLevR5YPw2mOOKgLllmpCJsjqMkUUF1SLI503ZK2hVH6FdSntBS\nYDbQVJVQ8j3M71eKr/D8Z5wN4Px41Y2bTke+xXm/2x5YRkZdtLCx/rbXPnYLruhG\n/C7aLqlA/ykQV0AWQgu1tc5gnAcT3mb/3y7GlybC8poMNPcEWic05hBJhpxlDNll\nwmUpcLEI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tWvlYM2BEByc8RI+b7DFCJz/KFzQ0xo0ymOonc+u2CQCihBSIisx\nWBn1D08CgYEAybW4F0uPy0jMg7fJCXzNOnwurKyAH7Uej7ZCAOJ/I1RRdGo6A0bZ\nneuo3I758vX7jT6itMw/D35J5cm2DAAVgYhaECLg1qWTLaoJDcEQys5VmL6gBh8w\ngaY1BQkhja1FqA7OcEylRUUWFgO3bWvHchOagVZUyipnYaq5KSwNhvA=\n-----END RSA PRIVATE KEY-----",
"unmatchCert": "-----BEGIN CERTIFICATE-----\nMIIENzCCAx+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCQ04x\nEjAQBgNVBAgMCUd1YW5nZG9uZzESMBAGA1UEBwwJR3Vhbmd6aG91MRQwEgYDVQQK\n-----END CERTIFICATE-----",
"unmatchKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAzt2VU3JAtNkiUhC/FKA0D3z9gRHaNR2+JYqnMHbetXJXF0oh\nWMKzjmzauaMYXUDPfQ8yc7leR6Gj9Ow5A0sUwlSdH1P0viM1gnQj0kLxeb59vQaW\n-----END RSA PRIVATE KEY-----"
}
74 changes: 74 additions & 0 deletions web/cypress/integration/ssl/ssl-smoketest.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-undef */

context('ssl smoke test', () => {
const domSelectors = {
notificationDesc: '.ant-notification-notice-description',
notificationMsg: '.ant-notification-notice-message'
};

beforeEach(() => {
// init login
cy.login();
cy.fixture('certificate.json').as('certificate');
})

it('should set match certificate and key by input', function () { // use `function () if used `fixture` above`
// go to ssl create page
cy.visit('/');
cy.contains('SSL').click();
cy.wait(500);
cy.contains('Create').click();

const matchCert = this.certificate.matchCert;
const matchKey = this.certificate.matchKey;
cy.get('#cert').type(matchCert);
cy.get('#key').type(matchKey);

cy.contains('Next').click();
cy.contains('Submit').click();
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
cy.wait(500);
cy.url().should('contains', 'ssl/list');
});

it('should delete the ssl record just created', () => {
cy.visit('/');
cy.contains('SSL').click();
cy.wait(500);
cy.contains('*.www.testhj.com').parents().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelectors.notificationMsg).should('contain', 'Remove target SSL successfully');
});

it('should set unmatch certificate and key by input', function () {
// go to ssl create page
cy.visit('/');
cy.contains('SSL').click();
cy.wait(500);
cy.contains('Create').click();

const unmatchCert = this.certificate.unmatchCert;
const unmatchKey = this.certificate.unmatchKey;
cy.get('#cert').type(unmatchCert);
cy.get('#key').type(unmatchKey);

cy.contains('Next').click();
cy.wait(100);
cy.get(domSelectors.notificationDesc).should('contain', "key and cert don't match");
});
})