You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2020/12/26 00:30:22 UTC

[apisix-dashboard] branch master updated: test: add frontend e2e test (smoke test for ssl) (#1096)

This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new de3c03e  test: add frontend e2e test (smoke test for ssl) (#1096)
de3c03e is described below

commit de3c03e94b0487685245d615457bd242dd8ca11a
Author: idbeta <id...@gmail.com>
AuthorDate: Sat Dec 26 08:30:13 2020 +0800

    test: add frontend e2e test (smoke test for ssl) (#1096)
    
    * test: add frontend e2e test (smoke test for ssl)
    resolve #641
    
    * fix: add waiting time
    
    * more test
    
    * fix: modify the delete method
    
    * test: used fixture instead of code
    
    * test: modify certificate.json to add `sni`
    
    * Update certificate.json
    
    Co-authored-by: YuanSheng Wang <me...@gmail.com>
    Co-authored-by: 琚致远 <ju...@apache.org>
    Co-authored-by: litesun <su...@apache.org>
---
 web/cypress/fixtures/certificate.json             | 11 ++++
 web/cypress/integration/ssl/ssl-smoketest.spec.js | 75 +++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/web/cypress/fixtures/certificate.json b/web/cypress/fixtures/certificate.json
new file mode 100644
index 0000000..a7a36d7
--- /dev/null
+++ b/web/cypress/fixtures/certificate.json
@@ -0,0 +1,11 @@
+{
+	"valid": {
+		"cert": "-----BEGIN CERTIFICATE-----\nMIIENzCCAx+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCQ04x\nEjAQBgNVBAgMCUd1YW5nZG9uZzESMBAGA1UEBwwJR3Vhbmd6aG91MRQwEgYDVQQK\nDAtGaXNoZHJvd25lZDEcMBoGA1UEAwwTRmlzaGRyb3duZWQgUk9PVCBDQTAeFw0y\nMDExMDYwOTQ3NDhaFw0yMjExMDYwOTQ3NDhaMH8xCzAJBgNVBAYTAkNOMRIwEAYD\nVQQIDAlHdWFuZ2RvbmcxEjAQBgNVBAcMCUd1YW5nemhvdTEUMBIGA1UECgwLRmlz\naGRyb3duZWQxFzAVBgNVBAsMDnd3dy50ZXN0aGouY29tMRkwFwYDVQQDDBAqLnd3\ndy50ZXN0aGouY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC [...]
+		"key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAzt2VU3JAtNkiUhC/FKA0D3z9gRHaNR2+JYqnMHbetXJXF0oh\nWMKzjmzauaMYXUDPfQ8yc7leR6Gj9Ow5A0sUwlSdH1P0viM1gnQj0kLxeb59vQaW\nSNuPm73C26R6en/Jgu8I09c+gsBkhNykcnLevR5YPw2mOOKgLllmpCJsjqMkUUF1\nSLI503ZK2hVH6FdSntBSYDbQVJVQ8j3M71eKr/D8Z5wN4Px41Y2bTke+xXm/2x5Y\nRkZdtLCx/rbXPnYLruhG/C7aLqlA/ykQV0AWQgu1tc5gnAcT3mb/3y7GlybC8poM\nNPcEWic05hBJhpxlDNllwmUpcLEI3orAfbZnBwIDAQABAoIBAQCGvLCMP3iB0oOW\nLC4pAwelpuV+8d/MhOjajurCmEoKqMSs+K2roHVPKPt1uhMeeh4q+ [...]
+		"sni": "*.www.testhj.com"
+	},
+	"invalid": {
+		"cert": "-----BEGIN CERTIFICATE-----\nMIIENzCCAx+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCQ04x\nEjAQBgNVBAgMCUd1YW5nZG9uZzESMBAGA1UEBwwJR3Vhbmd6aG91MRQwEgYDVQQK\n-----END CERTIFICATE-----",
+		"key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAzt2VU3JAtNkiUhC/FKA0D3z9gRHaNR2+JYqnMHbetXJXF0oh\nWMKzjmzauaMYXUDPfQ8yc7leR6Gj9Ow5A0sUwlSdH1P0viM1gnQj0kLxeb59vQaW\n-----END RSA PRIVATE KEY-----"
+	}
+}
diff --git a/web/cypress/integration/ssl/ssl-smoketest.spec.js b/web/cypress/integration/ssl/ssl-smoketest.spec.js
new file mode 100644
index 0000000..307bb3b
--- /dev/null
+++ b/web/cypress/integration/ssl/ssl-smoketest.spec.js
@@ -0,0 +1,75 @@
+/*
+ * 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 validCert = this.certificate.valid.cert;
+    const validKey = this.certificate.valid.key;
+    cy.get('#cert').type(validCert);
+    cy.get('#key').type(validKey);
+
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+    cy.wait(500);
+    cy.url().should('contains', 'ssl/list');
+  });
+
+  it('should delete the ssl record just created', function () {
+    cy.visit('/');
+    cy.contains('SSL').click();
+    cy.wait(500);
+    const sni = this.certificate.valid.sni;
+    cy.contains(sni).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 invalidCert = this.certificate.invalid.cert;
+    const invalidKey = this.certificate.invalid.key;
+    cy.get('#cert').type(invalidCert);
+    cy.get('#key').type(invalidKey);
+
+    cy.contains('Next').click();
+    cy.wait(100);
+    cy.get(domSelectors.notificationDesc).should('contain', "key and cert don't match");
+  });
+})