|
| 1 | +/* |
| 2 | +Copyright © 2021 the Konveyor Contributors (https://konveyor.io/) |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | +/// <reference types="cypress" /> |
| 17 | + |
| 18 | +import * as data from "../../../../utils/data_utils"; |
| 19 | +import { deleteApplicationTableRows, exists, login, sidedrawerTab } from "../../../../utils/utils"; |
| 20 | +import { CredentialsSourceControlUsername } from "../../../models/administration/credentials/credentialsSourceControlUsername"; |
| 21 | +import { SourcePlatform } from "../../../models/administration/source-platform/source-platform"; |
| 22 | +import { CredentialType, UserCredentials } from "../../../types/constants"; |
| 23 | + |
| 24 | +let cfCreds: CredentialsSourceControlUsername; |
| 25 | +let cfInstance: SourcePlatform; |
| 26 | + |
| 27 | +describe(["@tier1"], "Cloud Foundry discovery", () => { |
| 28 | + before("Verify Cloud Foundry env variables are present", function () { |
| 29 | + if ( |
| 30 | + !Cypress.env("cloudfoundry_user") || |
| 31 | + !Cypress.env("cloudfoundry_password") || |
| 32 | + !Cypress.env("cloudfoundry_url") |
| 33 | + ) { |
| 34 | + throw new Error(`One or more required Cloud Foundry env variables are missing in cypress.config.ts : |
| 35 | + \ncloudfoundry_user\ncloudfoundry_password\ncloudfoundry_url`); |
| 36 | + } |
| 37 | + login(); |
| 38 | + cy.visit("/"); |
| 39 | + deleteApplicationTableRows(); |
| 40 | + cfCreds = new CredentialsSourceControlUsername( |
| 41 | + data.getRandomCredentialsData( |
| 42 | + CredentialType.sourceControl, |
| 43 | + UserCredentials.usernamePassword, |
| 44 | + false, |
| 45 | + null, |
| 46 | + null, |
| 47 | + true |
| 48 | + ) |
| 49 | + ); |
| 50 | + cfCreds.name = `CF-CREDS-${data.getRandomNumber(1, 500)}`; |
| 51 | + cfCreds.create(); |
| 52 | + |
| 53 | + cfInstance = new SourcePlatform( |
| 54 | + `CF-${data.getRandomNumber(1, 500)}`, |
| 55 | + "Cloud Foundry", |
| 56 | + Cypress.env("cloudfoundry_url"), |
| 57 | + cfCreds.name |
| 58 | + ); |
| 59 | + cfInstance.create(); |
| 60 | + }); |
| 61 | + |
| 62 | + it("Discover a single CF application", function () { |
| 63 | + const CFApp = "hello-spring-cloud"; |
| 64 | + cfInstance.discover(CFApp, "space"); |
| 65 | + |
| 66 | + // Click 'Applications' link for the CF instance |
| 67 | + cy.contains(cfInstance.name) |
| 68 | + .closest("tr") |
| 69 | + .find('a[href*="applications"]') |
| 70 | + .click({ force: true }); |
| 71 | + exists(CFApp); |
| 72 | + |
| 73 | + // Verify discovery manifest is generated for the CF app |
| 74 | + sidedrawerTab(CFApp, "Platform"); |
| 75 | + cy.contains("Application discovery manifest") |
| 76 | + .parents(".drawer-tab-content__section") |
| 77 | + .find('[class*="code-editor__code"]') |
| 78 | + .should("exist"); |
| 79 | + }); |
| 80 | + |
| 81 | + after("Clear test data", function () { |
| 82 | + deleteApplicationTableRows(); |
| 83 | + cfInstance.delete(); |
| 84 | + cfCreds.delete(); |
| 85 | + }); |
| 86 | +}); |
0 commit comments