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

Rename to AzureSpringApps #17471

Merged
merged 21 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"loc.friendlyName": "Azure Spring Cloud",
"loc.helpMarkDown": "[Learn more about this task](https://aka.ms/azurespringcloud)",
"loc.description": "Deploy applications to Azure Spring Cloud and manage deployments.",
"loc.instanceNameFormat": "Azure Spring Cloud $(Action): $(AppName)",
"loc.friendlyName": "Azure Spring Apps",
"loc.helpMarkDown": "[Learn more about this task](https://aka.ms/azurespringapps)",
"loc.description": "Deploy applications to Azure Spring Apps and manage deployments.",
"loc.instanceNameFormat": "Azure Spring Apps $(Action): $(AppName)",
"loc.group.displayName.ApplicationAndConfigurationSettings": "Application and Configuration Settings",
"loc.input.label.ConnectedServiceName": "Azure subscription",
"loc.input.help.ConnectedServiceName": "Select the Azure Resource Manager subscription for the deployment.",
"loc.input.label.Action": "Action",
"loc.input.help.Action": "Action to be performed on Azure Spring Cloud.",
"loc.input.label.AzureSpringCloud": "Azure Spring Cloud Name",
"loc.input.help.AzureSpringCloud": "Select the Azure Spring Cloud service to which to deploy.",
"loc.input.help.Action": "Action to be performed on Azure Spring Apps.",
"loc.input.label.AzureSpringCloud": "Azure Spring Apps Name",
"loc.input.help.AzureSpringCloud": "Select the Azure Spring Apps service to which to deploy.",
"loc.input.label.AppName": "App",
"loc.input.help.AppName": "Select the Azure Spring Cloud app to deploy.",
"loc.input.help.AppName": "Select the Azure Spring Apps app to deploy.",
"loc.input.label.DeploymentType": "Deployment Type",
"loc.input.help.DeploymentType": "To deploy with source code or Java package, choose \"Artifacts\"; To deploy with container image, choose \"Custom Container\"",
"loc.input.label.UseStagingDeployment": "Use Staging Deployment",
Expand All @@ -21,9 +21,9 @@
"loc.input.label.DeploymentName": "Deployment",
"loc.input.help.DeploymentName": "The deployment to which this task will apply. Lowercase letters and numbers only; must start with a letter.",
"loc.input.label.Package": "Package or folder",
"loc.input.help.Package": "File path to the package or a folder containing the Spring Cloud app contents.<br />Variables ( [Build](https://docs.microsoft.com/vsts/pipelines/build/variables) | [Release](https://docs.microsoft.com/vsts/pipelines/release/variables#default-variables)), wildcards are supported. <br/> For example, $(System.DefaultWorkingDirectory)/\\*\\*/\\*.jar.",
"loc.input.help.Package": "File path to the package or a folder containing the Spring Apps app contents.<br />Variables ( [Build](https://docs.microsoft.com/vsts/pipelines/build/variables) | [Release](https://docs.microsoft.com/vsts/pipelines/release/variables#default-variables)), wildcards are supported. <br/> For example, $(System.DefaultWorkingDirectory)/\\*\\*/\\*.jar.",
"loc.input.label.Builder": "Builder",
"loc.input.help.Builder": "Select a builder of VMware Tanzu® Build Service™, this can be used in enterprise tier. <br/> For detailed description, please check [Use Tanzu Build Service](https://docs.microsoft.com/en-us/azure/spring-cloud/how-to-enterprise-build-service?tabs=azure-portal).",
"loc.input.help.Builder": "Select a builder of VMware Tanzu® Build Service™, this can be used in enterprise tier. <br/> For detailed description, please check [Use Tanzu Build Service](https://docs.microsoft.com/en-us/azure/spring-apps/how-to-enterprise-build-service?tabs=azure-portal).",
"loc.input.label.RegistryServer": "Registry Server",
"loc.input.help.RegistryServer": "The registry of the container image. Default: docker.io.",
"loc.input.label.RegistryUsername": "Registry Username",
Expand Down Expand Up @@ -52,7 +52,7 @@
"loc.messages.StartingUploadOf": "Starting upload of %s",
"loc.messages.CompletedUploadOf": "Upload of %s completed.",
"loc.messages.ResourceDoesntExist": "Resource '%s' doesn't exist. Resource should exist before deployment.",
"loc.messages.UnableToGetDeploymentUrl": "Unable to get deployment URL for Azure Spring Cloud '%s', Error: '%s'",
"loc.messages.UnableToGetDeploymentUrl": "Unable to get deployment URL for Azure Spring Apps '%s', Error: '%s'",
"loc.messages.DeploymentDoesntExist": "Deployment with name '%s' does not exist. Unable to proceed.",
"loc.messages.StagingDeploymentWithNameDoesntExist": "Staging deployment with name %s does not exist. Unable to proceed.",
"loc.messages.NoStagingDeploymentFound": "No staging deployment found.",
Expand All @@ -66,8 +66,8 @@
"loc.messages.UnableToRetrieveTestEndpointKeys": "Unable to retrieve test endpoint keys",
"loc.messages.NoDeploymentsExist": "No deployments exist.",
"loc.messages.UnableToGetDeploymentInformation": "Unable to get deployment information.",
"loc.messages.DuplicateAzureSpringCloudName": "Illegal state: multiple Azure Spring Cloud instances with same name.",
"loc.messages.InvalidAzureSpringCloudResourceId": "Invalid azure spring cloud resource identifier: %s",
"loc.messages.DuplicateAzureSpringAppsName": "Illegal state: multiple Azure Spring Apps instances with same name.",
"loc.messages.InvalidAzureSpringAppsResourceId": "Invalid Azure Spring Apps resource identifier: %s",
"loc.messages.Nopackagefoundwithspecifiedpattern": "No package found with specified pattern: %s. Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.",
"loc.messages.MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern": "More than one package matched with specified pattern: %s. Please restrain the search pattern."
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import assert = require('assert');
import { AzureSpringCloudDeploymentProvider } from "../deploymentProvider/AzureSpringCloudDeploymentProvider"
import { AzureSpringAppsDeploymentProvider } from "../deploymentProvider/AzureSpringAppsDeploymentProvider"
import { TaskParameters } from "../operations/taskparameters"


export class AzureSpringCloudUnitTests {
export class AzureSpringAppsUnitTests {

public static pathTraversalAttackTest = (done: Mocha.Done) => {
const resourceIdWithPathAttack = '/subscriptions/mocksubid/resourceGroups/mockresouorcegroup/providers/Microsoft.AppPlatform/Spring/authorized-name/../unauthorized-name';
const taskParameters: TaskParameters = {
AzureSpringCloud: resourceIdWithPathAttack,
AzureSpringApps: resourceIdWithPathAttack,
AppName: 'appName',
UseStagingDeployment: false,
Action: 'Deploy'
};

const provider = new AzureSpringCloudDeploymentProvider(taskParameters);
const provider = new AzureSpringAppsDeploymentProvider(taskParameters);
provider.PreDeploymentStep().then(() => {
done(assert.fail('Attempted path traversal attack should have failed'));
}).catch(error => {
assert.strictEqual(error.message, `loc_mock_InvalidAzureSpringCloudResourceId ${resourceIdWithPathAttack}`);
assert.strictEqual(error.message, `loc_mock_InvalidAzureSpringAppsResourceId ${resourceIdWithPathAttack}`);
done();
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@

import { AzureEndpoint } from "azure-pipelines-tasks-azure-arm-rest-v2/azureModels";
import { getMockEndpoint, nock } from '../node_modules/azure-pipelines-tasks-azure-arm-rest-v2/Tests/mock_utils';
import { getMockEndpoint, nock } from 'azure-pipelines-tasks-azure-arm-rest-v2/Tests/mock_utils';
import { MOCK_RESOURCE_GROUP_NAME, API_VERSION } from "./mock_utils";
import assert = require('assert');

export class AzureSpringCloudUnitTests {
export class AzureSpringAppsUnitTests {

static readonly AZURE_ENDPOINT: AzureEndpoint = getMockEndpoint();

/**
* Tests that deployment names are parsed correctly from API output.
*/
public static testDeploymentNameRetrieval = (done: Mocha.Done) => {
let azureSpringCloudName = 'testDeploymentNameRetrieval';
let azureSpringAppsName = 'testDeploymentNameRetrieval';
let appName = 'testapp';
let azureSpringCloud = AzureSpringCloudUnitTests.newAzureSpringCloud(azureSpringCloudName);
AzureSpringCloudUnitTests.mockDeploymentListApiWithTwoDeployments(azureSpringCloudName, appName);
let azureSpringApps = AzureSpringAppsUnitTests.newAzureSpringApps(azureSpringAppsName);
AzureSpringAppsUnitTests.mockDeploymentListApiWithTwoDeployments(azureSpringAppsName, appName);
let expectedDeploymentNames = ['default', 'theOtherOne'];
azureSpringCloud.getAllDeploymentNames(appName)
azureSpringApps.getAllDeploymentNames(appName)
.then(foundDeploymentNames => {
assert.deepStrictEqual(foundDeploymentNames, expectedDeploymentNames);
done();
})
.catch(error => done(error));
}

/** Prepares an instance of the AzureSpringCloudWrapper with a mock endpoint */
private static newAzureSpringCloud(name: string) {
let asc = require('../deploymentProvider/azure-arm-spring-cloud');
let azureSpringCloud = new asc.AzureSpringCloud(this.AZURE_ENDPOINT, `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${MOCK_RESOURCE_GROUP_NAME}/providers/Microsoft.AppPlatform/Spring/${name}`)
return azureSpringCloud;
/** Prepares an instance of the AzureSpringAppsWrapper with a mock endpoint */
private static newAzureSpringApps(name: string) {
let asa = require('../deploymentProvider/azure-arm-spring-apps');
let azureSpringApps = new asa.AzureSpringApps(this.AZURE_ENDPOINT, `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${MOCK_RESOURCE_GROUP_NAME}/providers/Microsoft.AppPlatform/Spring/${name}`)
return azureSpringApps;
}

private static mockDeploymentListApiWithTwoDeployments(azureSpringCloudName: string, appName: string) {
private static mockDeploymentListApiWithTwoDeployments(azureSpringAppsName: string, appName: string) {
console.log('mockDeploymentListApiWithTwoDeployments');

nock('https://management.azure.com').get(`/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringCloudName}/apps/${appName}/deployments?api-version=${API_VERSION}`)
nock('https://management.azure.com').get(`/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringAppsName}/apps/${appName}/deployments?api-version=${API_VERSION}`)
.reply(200, {
"value": [
{
"id": `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringCloudName}/apps/${appName}/deployments/default`,
"id": `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringAppsName}/apps/${appName}/deployments/default`,
"name": "default",
"properties": {
"active": true,
Expand Down Expand Up @@ -74,7 +74,7 @@ export class AzureSpringCloudUnitTests {
"type": `providers/Microsoft.AppPlatform/Spring/apps/deployments`
},
{
"id": `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringCloudName}/apps/${appName}/deployments/theOtherOne`,
"id": `/subscriptions/${this.AZURE_ENDPOINT.subscriptionID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/Microsoft.AppPlatform/Spring/${azureSpringAppsName}/apps/${appName}/deployments/theOtherOne`,
"name": "theOtherOne",
"properties": {
"active": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, mockCommonAzureAPIs, nock, mockAzureSpringCloudExists, API_VERSION } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, mockCommonAzureAPIs, nock, mockAzureSpringAppsExists, API_VERSION } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME, MOCK_SUBSCRIPTION_ID } from './mock_utils'

const TEST_APP_NAME = 'testapp';
Expand All @@ -11,12 +11,12 @@ export class CreateNamedDeploymentFailsDeploymentDoesNotAlreadyExistL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockDeploymentListApiWithTwoDeployments();
taskMockRunner.setAnswers(mockTaskArgument());
taskMockRunner.run();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, mockCommonAzureAPIs, nock, mockAzureSpringCloudExists, printTaskInputs, API_VERSION } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, mockCommonAzureAPIs, nock, mockAzureSpringAppsExists, printTaskInputs, API_VERSION } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME, MOCK_SUBSCRIPTION_ID } from './mock_utils'

const TEST_APP_NAME = 'testapp';
Expand All @@ -11,12 +11,12 @@ export class CreateNamedDeploymentFailsWhenTwoDeploymentsExistL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockDeploymentListApiWithTwoDeployments();
taskMockRunner.setAnswers(mockTaskArgument());
taskMockRunner.run();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringCloudExists, mockCommonAzureAPIs } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringAppsExists, mockCommonAzureAPIs } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME } from './mock_utils'
import assert = require('assert');

Expand All @@ -12,12 +12,12 @@ export class DeleteStagingDeploymentTestL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockSingleDeployment();
this.mockDeploymentDeleteStagingDeployment();
taskMockRunner.setAnswers(mockTaskArgument());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringCloudExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringAppsExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME } from './mock_utils'
import assert = require('assert');

Expand All @@ -11,12 +11,12 @@ export class DeleteStagingDeploymentTestL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockTwoDeployments();
this.mockDeploymentDeleteStagingDeployment();
taskMockRunner.setAnswers(mockTaskArgument());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringCloudExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringAppsExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME } from './mock_utils'
import assert = require('assert');

Expand All @@ -15,12 +15,12 @@ export class DeploymentCustomImageToStagingSucceedsL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockTwoDeployments();
let nockScope = this.mockDeploymentApis();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import tmrm = require('azure-pipelines-task-lib/mock-run');
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringCloudExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { setEndpointData, setAgentsData, mockTaskArgument, nock, MOCK_SUBSCRIPTION_ID, mockAzureSpringAppsExists, mockCommonAzureAPIs, API_VERSION } from './mock_utils';
import { ASC_RESOURCE_TYPE, MOCK_RESOURCE_GROUP_NAME } from './mock_utils'
import assert = require('assert');

Expand All @@ -16,12 +16,12 @@ export class DeploymentFailsWhenBuilderNotExistL0 {

public static startTest() {
console.log(`running ${this.TEST_NAME}`);
let taskPath = path.join(__dirname, '..', 'azurespringclouddeployment.js');
let taskPath = path.join(__dirname, '..', 'azurespringappsdeployment.js');
let taskMockRunner: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
setEndpointData();
setAgentsData();
mockCommonAzureAPIs();
mockAzureSpringCloudExists(this.TEST_NAME);
mockAzureSpringAppsExists(this.TEST_NAME);
this.mockTwoDeployments();
let nockScope = this.mockDeploymentApis();

Expand Down
Loading