Skip to content

Commit

Permalink
Added functionality for HTTP authentication promotion and Integration…
Browse files Browse the repository at this point in the history
… account schema xslt name promotion
  • Loading branch information
MLogdberg committed Jun 11, 2017
1 parent be5f42c commit 4b14143
Show file tree
Hide file tree
Showing 6 changed files with 475 additions and 18 deletions.
3 changes: 3 additions & 0 deletions LogicAppTemplate.Test/LogicAppTemplate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<EmbeddedResource Include="TestFiles\WorkflowTestOtherResourcegroup.json" />
<EmbeddedResource Include="TestFiles\file-test-readfolder.json" />
<EmbeddedResource Include="TestFiles\parameter-test-object.json" />
<EmbeddedResource Include="TestFiles\IntegrationAccount-FlatFileAndTransform.json" />
<EmbeddedResource Include="TestFiles\HTTP-Authentication.json" />
<EmbeddedResource Include="TestFiles\HTTP-basic.json" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
Expand Down
81 changes: 63 additions & 18 deletions LogicAppTemplate.Test/TemplateGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,7 @@ public void ParameterTestTypeObject()
Assert.AreEqual(571, (int)defintion["parameters"]["paramismanager"]["defaultValue"]["1"]);
Assert.AreEqual(572, (int)defintion["parameters"]["paramismanager"]["defaultValue"]["No"]);
Assert.AreEqual(571, (int)defintion["parameters"]["paramismanager"]["defaultValue"]["Yes"]);
Assert.AreEqual("Object", defintion["parameters"]["paramismanager"]["type"]);
/*
dynamic obj = new System.Dynamic.ExpandoObject();
obj.type = "Object";
obj.defaultValue = new System.Dynamic.ExpandoObject();
((IDictionary<string, object>)obj.defaultValue)["0"] = 572;
((IDictionary<string, object>)obj.defaultValue)["1"] = 571;
obj.defaultValue.No = 572;
obj.defaultValue.Yes = 571;
var p = new JProperty("paramismanager", JObject.FromObject(obj));
Assert.AreEqual(JObject.FromObject(obj), (JObject)defintion["parameters"]["paramismanager"]); */
//check parameters


//Assert.AreEqual("[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/', parameters('apimResourceGroup'),'/providers/Microsoft.ApiManagement/service/', parameters('apimInstanceName'),'/apis/', parameters('apimApiId'),'')]", defintion["resources"][0]["properties"]["definition"]["actions"]["Condition"]["actions"]["Switch"]["default"]["actions"]["INT002_Create_Actioncode_2"]["inputs"]["api"]["id"]);
//Assert.AreEqual("[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/', parameters('apimResourceGroup'),'/providers/Microsoft.ApiManagement/service/', parameters('apimInstanceName'),'/apis/', parameters('apimApiId'),'')]", defintion["resources"][0]["properties"]["definition"]["actions"]["Condition"]["actions"]["Switch"]["cases"]["Case"]["actions"]["For_each"]["actions"]["INT002_Create_Actioncode"]["inputs"]["api"]["id"]);
//check nested nested action
Assert.AreEqual("Object", defintion["parameters"]["paramismanager"]["type"]);

}

Expand Down Expand Up @@ -284,6 +267,68 @@ public void TestFileLogicApp()
//Assert.AreEqual("[base64(parameters('When_a_file_is_created-folderPath'))]", defintion["resources"][0]["properties"]["definition"]["triggers"]["When_a_file_is_created"]["inputs"]["queries"]["folderId"]);
}

[TestMethod()]
public void TestIntegrationAccount()
{
var content = GetEmbededFileContent("LogicAppTemplate.Test.TestFiles.IntegrationAccount-FlatFileAndTransform.json");

var generator = new TemplateGenerator();

var defintion = generator.generateDefinition(JObject.Parse(content)).GetAwaiter().GetResult();

//check parameters
Assert.AreEqual(defintion["parameters"]["IntegrationAccountName"]["defaultValue"], "ia");
Assert.AreEqual(defintion["parameters"]["IntegrationAccountResourceGroupName"]["defaultValue"], "[resourceGroup().name]");
Assert.AreEqual(defintion["parameters"]["Flat_File_Decoding-SchemaName"]["defaultValue"], "TEST-INT0021.Scorpio.DailyStatistics");
Assert.AreEqual(defintion["parameters"]["Flat_File_Encoding-SchemaName"]["defaultValue"], "TEST-INT0021.Intime.DailyStatistics");
Assert.AreEqual(defintion["parameters"]["Transform_XML-MapName"]["defaultValue"], "TEST-INT0021.DailyStatistics.Scorpio.To.Intime");


//check nested nested action

}


[TestMethod()]
public void TestHTTP()
{
var content = GetEmbededFileContent("LogicAppTemplate.Test.TestFiles.HTTP-basic.json");

var generator = new TemplateGenerator();

var defintion = generator.generateDefinition(JObject.Parse(content)).GetAwaiter().GetResult();

//check parameters
Assert.AreEqual(defintion["parameters"]["HTTP-URI"]["defaultValue"], "http://google.se");


}

[TestMethod()]
public void TestHTTPAuthentication()
{
var content = GetEmbededFileContent("LogicAppTemplate.Test.TestFiles.HTTP-Authentication.json");

var generator = new TemplateGenerator();

var defintion = generator.generateDefinition(JObject.Parse(content)).GetAwaiter().GetResult();

//check parameters basic auth
Assert.AreEqual(defintion["parameters"]["HTTP-Password"]["defaultValue"], "bbb");
Assert.AreEqual(defintion["parameters"]["HTTP-Username"]["defaultValue"], "aa");

//check parameters certificate auth
Assert.AreEqual(defintion["parameters"]["HTTP_2-Password"]["defaultValue"], "mypassword");
Assert.AreEqual(defintion["parameters"]["HTTP_2-Pfx"]["defaultValue"], "pfxcontent");

//check parameters oauth AAD
Assert.AreEqual(defintion["parameters"]["HTTP_3-Audience"]["defaultValue"], "myaudience");
Assert.AreEqual(defintion["parameters"]["HTTP_3-Authority"]["defaultValue"], "https://login.microsoft.com/my");
Assert.AreEqual(defintion["parameters"]["HTTP_3-ClientId"]["defaultValue"], "myclientid");
Assert.AreEqual(defintion["parameters"]["HTTP_3-Secret"]["defaultValue"], "mysecret");
Assert.AreEqual(defintion["parameters"]["HTTP_3-Tenant"]["defaultValue"], "mytenant");
}

//var resourceName = "LogicAppTemplate.Templates.starterTemplate.json";
private static string GetEmbededFileContent(string resourceName)
{
Expand Down
154 changes: 154 additions & 0 deletions LogicAppTemplate.Test/TestFiles/HTTP-Authentication.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"properties": {
"provisioningState": "Succeeded",
"createdTime": "2016-03-29T11:46:20.905923Z",
"changedTime": "2017-06-11T10:47:39.040243Z",
"state": "Disabled",
"version": "08587044288264688388",
"accessEndpoint": "https://prod-05.northeurope.logic.azure.com:443/workflows/05b414ebdcc1445ab66c964899d5c488",
"sku": {
"name": "Free",
"plan": {
"name": "Default1",
"id": "/subscriptions/FAKE9af-ec2b-4d0f-8cf8-105fa828600a/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.Web/serverFarms/Default1",
"type": "Microsoft.Web/ServerFarms"
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2015-08-01-preview/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"triggers": {
"manual": {
"type": "Manual",
"inputs": {
"schema": {
"properties": {
"test": {
"properties": {
"data": {
"properties": {
"tredje": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
}
}
}
},
"actions": {
"HTTP": {
"type": "Http",
"inputs": {
"authentication": {
"password": "bbb",
"type": "Basic",
"username": "aa"
},
"body": {
"test": "data"
},
"method": "POST",
"uri": "http://google.se"
},
"conditions": []
},
"HTTP_2": {
"type": "Http",
"inputs": {
"authentication": {
"password": "mypassword",
"pfx": "pfxcontent",
"type": "ClientCertificate"
},
"method": "POST",
"uri": "http://google.se"
},
"conditions": [
{
"dependsOn": "HTTP"
}
]
},
"HTTP_3": {
"type": "Http",
"inputs": {
"authentication": {
"audience": "myaudience",
"authority": "https://login.microsoft.com/my",
"clientId": "myclientid",
"secret": "mysecret",
"tenant": "mytenant",
"type": "ActiveDirectoryOAuth"
},
"method": "GET",
"uri": "http://google.se"
},
"conditions": [
{
"dependsOn": "HTTP_2"
}
]
},
"Response": {
"type": "Response",
"inputs": {
"body": "@coalesce(triggerBody()?['test']?['data']?['tredje'],'nullat')",
"statusCode": 200
},
"conditions": [
{
"dependsOn": "HTTP_3"
}
]
}
},
"outputs": {}
},
"parameters": {},
"endpointsConfiguration": {
"workflow": {
"outgoingIpAddresses": [
{
"address": "40.113.12.95"
},
{
"address": "52.178.165.215"
},
{
"address": "52.178.166.21"
}
],
"accessEndpointIpAddresses": [
{
"address": "13.79.173.49"
},
{
"address": "52.169.218.253"
},
{
"address": "52.169.220.174"
}
]
},
"connector": {
"outgoingIpAddresses": [
{
"address": "104.45.93.9"
}
]
}
}
},
"id": "/subscriptions/FAKE9af-ec2b-4d0f-8cf8-105fa828600a/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.Logic/workflows/test",
"name": "test",
"type": "Microsoft.Logic/workflows",
"location": "northeurope"
}
113 changes: 113 additions & 0 deletions LogicAppTemplate.Test/TestFiles/HTTP-basic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"properties": {
"provisioningState": "Succeeded",
"createdTime": "2016-03-29T11:46:20.905923Z",
"changedTime": "2017-06-11T10:47:39.040243Z",
"state": "Disabled",
"version": "08587044288264688388",
"accessEndpoint": "https://prod-05.northeurope.logic.azure.com:443/workflows/05b414ebdcc1445ab66c964899d5c488",
"sku": {
"name": "Free",
"plan": {
"name": "Default1",
"id": "/subscriptions/FAKE9af-ec2b-4d0f-8cf8-105fa828600a/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.Web/serverFarms/Default1",
"type": "Microsoft.Web/ServerFarms"
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2015-08-01-preview/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"triggers": {
"manual": {
"type": "Manual",
"inputs": {
"schema": {
"properties": {
"test": {
"properties": {
"data": {
"properties": {
"tredje": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
}
}
}
},
"actions": {
"HTTP": {
"type": "Http",
"inputs": {
"body": {
"test": "data"
},
"method": "POST",
"uri": "http://google.se"
},
"conditions": []
},

"Response": {
"type": "Response",
"inputs": {
"body": "@coalesce(triggerBody()?['test']?['data']?['tredje'],'nullat')",
"statusCode": 200
},
"conditions": [
{
"dependsOn": "HTTP_3"
}
]
}
},
"outputs": {}
},
"parameters": {},
"endpointsConfiguration": {
"workflow": {
"outgoingIpAddresses": [
{
"address": "40.113.12.95"
},
{
"address": "52.178.165.215"
},
{
"address": "52.178.166.21"
}
],
"accessEndpointIpAddresses": [
{
"address": "13.79.173.49"
},
{
"address": "52.169.218.253"
},
{
"address": "52.169.220.174"
}
]
},
"connector": {
"outgoingIpAddresses": [
{
"address": "104.45.93.9"
}
]
}
}
},
"id": "/subscriptions/FAKE9af-ec2b-4d0f-8cf8-105fa828600a/resourceGroups/Default-Web-NorthEurope/providers/Microsoft.Logic/workflows/test",
"name": "test",
"type": "Microsoft.Logic/workflows",
"location": "northeurope"
}
Loading

0 comments on commit 4b14143

Please sign in to comment.