forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
599409b
commit afe631b
Showing
10 changed files
with
241 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...-appservice/src/test/java/com/microsoft/azure/management/appservice/HostnameSslTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.azure.management.appservice; | ||
|
||
import com.microsoft.azure.management.resources.fluentcore.arm.Region; | ||
import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import javax.net.ssl.SSLPeerUnverifiedException; | ||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
public class HostnameSslTests extends AppServiceTestBase { | ||
private static final String RG_NAME = ResourceNamer.randomResourceName("javacsmrg", 20); | ||
private static final String WEBAPP_NAME = ResourceNamer.randomResourceName("java-webapp-", 20); | ||
private static final String APP_SERVICE_PLAN_NAME = ResourceNamer.randomResourceName("java-asp-", 20); | ||
private static OkHttpClient httpClient = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build(); | ||
private String DOMAIN = domain.name(); | ||
|
||
@BeforeClass | ||
public static void setup() throws Exception { | ||
createClients(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanup() throws Exception { | ||
resourceManager.resourceGroups().deleteByName(RG_NAME); | ||
} | ||
|
||
@Test | ||
public void canBindHostnameAndSsl() throws Exception { | ||
// hostname binding | ||
appServiceManager.webApps().define(WEBAPP_NAME) | ||
.withNewResourceGroup(RG_NAME) | ||
.withNewAppServicePlan(APP_SERVICE_PLAN_NAME) | ||
.withRegion(Region.US_WEST) | ||
.withPricingTier(AppServicePricingTier.BASIC_B1) | ||
.defineHostnameBinding() | ||
.withAzureManagedDomain(domain) | ||
.withSubDomain(WEBAPP_NAME) | ||
.withDnsRecordType(CustomHostNameDnsRecordType.CNAME) | ||
.attach() | ||
.create(); | ||
|
||
WebApp webApp = appServiceManager.webApps().getByGroup(RG_NAME, WEBAPP_NAME); | ||
Assert.assertNotNull(webApp); | ||
Response response = curl("http://" + WEBAPP_NAME + "." + DOMAIN); | ||
Assert.assertEquals(200, response.code()); | ||
Assert.assertNotNull(response.body().string()); | ||
|
||
// hostname binding shortcut | ||
webApp.update() | ||
.withManagedHostnameBindings(domain, WEBAPP_NAME + "-1", WEBAPP_NAME + "-2") | ||
.apply(); | ||
response = curl("http://" + WEBAPP_NAME + "-1." + DOMAIN); | ||
Assert.assertEquals(200, response.code()); | ||
Assert.assertNotNull(response.body().string()); | ||
response = curl("http://" + WEBAPP_NAME + "-2." + DOMAIN); | ||
Assert.assertEquals(200, response.code()); | ||
Assert.assertNotNull(response.body().string()); | ||
|
||
// SSL binding | ||
webApp.update() | ||
.defineSslBinding() | ||
.forHostname(WEBAPP_NAME + "." + DOMAIN) | ||
.withExistingAppServiceCertificateOrder(certificateOrder) | ||
.withSniBasedSsl() | ||
.attach() | ||
.apply(); | ||
response = null; | ||
int retryCount = 3; | ||
while (response == null && retryCount > 0) { | ||
try { | ||
response = curl("https://" + WEBAPP_NAME + "." + DOMAIN); | ||
} catch (SSLPeerUnverifiedException e) { | ||
retryCount--; | ||
Thread.sleep(5000); | ||
} | ||
} | ||
if (retryCount == 0) { | ||
fail(); | ||
} | ||
Assert.assertEquals(200, response.code()); | ||
Assert.assertNotNull(response.body().string()); | ||
} | ||
|
||
private static Response curl(String url) throws IOException { | ||
Request request = new Request.Builder().url(url).get().build(); | ||
return httpClient.newCall(request).execute(); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
...ppservice/src/test/java/com/microsoft/azure/management/appservice/SourceControlTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.azure.management.appservice; | ||
|
||
import com.microsoft.azure.management.resources.fluentcore.arm.Region; | ||
import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class SourceControlTests extends AppServiceTestBase { | ||
private static final String RG_NAME = ResourceNamer.randomResourceName("javacsmrg", 20); | ||
private static final String WEBAPP_NAME = ResourceNamer.randomResourceName("java-webapp-", 20); | ||
private static final String SLOT_NAME = ResourceNamer.randomResourceName("java-slot-", 20); | ||
private static final String APP_SERVICE_PLAN_NAME = ResourceNamer.randomResourceName("java-asp-", 20); | ||
private static OkHttpClient httpClient = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build(); | ||
|
||
@BeforeClass | ||
public static void setup() throws Exception { | ||
createClients(); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanup() throws Exception { | ||
resourceManager.resourceGroups().deleteByName(RG_NAME); | ||
} | ||
|
||
@Test | ||
public void canDeploySourceControl() throws Exception { | ||
// Create web app | ||
WebApp webApp = appServiceManager.webApps().define(WEBAPP_NAME) | ||
.withNewResourceGroup(RG_NAME) | ||
.withNewAppServicePlan(APP_SERVICE_PLAN_NAME) | ||
.withRegion(Region.US_WEST) | ||
.withPricingTier(AppServicePricingTier.BASIC_B1) | ||
.defineSourceControl() | ||
.withPublicExternalRepository() | ||
.withGit("https://github.com/Azure-Samples/app-service-web-nodejs-get-started") | ||
.withBranch("master") | ||
.attach() | ||
.withConnectionString("StorageConnectionString", | ||
"DefaultEndpointsProtocol=https;AccountName=azurejsdkdemo;AccountKey=Brtk1ZZIiSdPAYATXJwwg8xyeWkyqUmJf0m1dH5caQZJSqKpPksUhHXeW9vo+fSg9BE7I+7dYFEWkZy+VQmCcw==", | ||
ConnectionStringType.CUSTOM) | ||
.create(); | ||
Assert.assertNotNull(webApp); | ||
Response response = curl("http://" + WEBAPP_NAME + "." + "azurewebsites.net"); | ||
Assert.assertEquals(200, response.code()); | ||
String body = response.body().string(); | ||
Assert.assertNotNull(body); | ||
Assert.assertTrue(body.contains("Hello world from linux 4")); | ||
|
||
|
||
// auto swap | ||
DeploymentSlot slot = webApp.deploymentSlots().define(SLOT_NAME) | ||
.withBrandNewConfiguration() | ||
.withPythonVersion(PythonVersion.PYTHON_27) | ||
.create(); | ||
Assert.assertNotNull(slot); | ||
Assert.assertNotEquals(JavaVersion.JAVA_1_7_0_51, slot.javaVersion()); | ||
Assert.assertEquals(PythonVersion.PYTHON_27, slot.pythonVersion()); | ||
Map<String, AppSetting> appSettingMap = slot.appSettings(); | ||
Assert.assertFalse(appSettingMap.containsKey("appkey")); | ||
Assert.assertFalse(appSettingMap.containsKey("stickykey")); | ||
Map<String, ConnectionString> connectionStringMap = slot.connectionStrings(); | ||
Assert.assertFalse(connectionStringMap.containsKey("connectionName")); | ||
Assert.assertFalse(connectionStringMap.containsKey("stickyName")); | ||
|
||
|
||
} | ||
|
||
private static Response curl(String url) throws IOException { | ||
Request request = new Request.Builder().url(url).get().build(); | ||
return httpClient.newCall(request).execute(); | ||
} | ||
} |
Oops, something went wrong.