2
0

ssl-smoketest.cy.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* eslint-disable no-undef */
  18. context('ssl smoke test', () => {
  19. const selector = {
  20. notificationMessage: '.ant-notification-notice-message',
  21. notificationDesc: '.ant-notification-notice-description',
  22. };
  23. const data = {
  24. deleteSSLSuccess: 'Remove target SSL successfully',
  25. sslErrorAlert: "key and cert don't match",
  26. };
  27. beforeEach(() => {
  28. cy.login();
  29. cy.fixture('certificate.json').as('certificate');
  30. });
  31. it('should set match certificate and key by input', function () {
  32. // use `function () if used `fixture` above`
  33. // go to ssl create page
  34. cy.visit('/');
  35. cy.contains('SSL').click();
  36. cy.contains('Create').click();
  37. const validCert = this.certificate.valid.cert;
  38. const validKey = this.certificate.valid.key;
  39. cy.get('#cert').type(validCert);
  40. cy.get('#key').type(validKey);
  41. cy.contains('Next').click();
  42. cy.contains('Submit').click();
  43. cy.url().should('contains', 'ssl/list');
  44. });
  45. it('should delete the ssl record just created', function () {
  46. cy.visit('/');
  47. cy.contains('SSL').click();
  48. const sni = this.certificate.valid.sni;
  49. cy.contains(sni).parents().contains('Delete').click();
  50. cy.contains('button', 'Confirm').click();
  51. cy.get(selector.notificationMessage).should('contain', data.deleteSSLSuccess);
  52. });
  53. it('should set unmatch certificate and key by input', function () {
  54. // go to ssl create page
  55. cy.visit('/');
  56. cy.contains('SSL').click();
  57. cy.contains('Create').click();
  58. const invalidCert = this.certificate.invalid.cert;
  59. const invalidKey = this.certificate.invalid.key;
  60. cy.get('#cert').type(invalidCert);
  61. cy.get('#key').type(invalidKey);
  62. cy.contains('Next').click();
  63. cy.get(selector.notificationDesc).should('contain', data.sslErrorAlert);
  64. });
  65. });