-
Notifications
You must be signed in to change notification settings - Fork 240
Adds Microsoft Azure provider #524
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -256,6 +256,7 @@ Providers | |
| * Avatar | ||
| * Aviation | ||
| * AWS | ||
| * Azure | ||
| * Babylon 5 | ||
| * Back To The Future | ||
| * Barcode | ||
|
|
||
This file contains hidden or 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,147 @@ | ||
| package net.datafaker.providers.base; | ||
|
|
||
|
|
||
| /** | ||
| * Generates data for Azure services. This is based on the Azure best practices of naming conventions: | ||
| * <a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-naming">...</a> | ||
| * <a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations">...</a> | ||
| * | ||
| * @since 1.7.0 | ||
| */ | ||
| public class Azure extends AbstractProvider<BaseProviders> { | ||
|
|
||
| protected Azure(BaseProviders faker) { | ||
| super(faker); | ||
| } | ||
|
|
||
| public String region() { | ||
| return resolve("azure.regions"); | ||
| } | ||
|
|
||
| public String subscriptionId() { | ||
| return faker.regexify("[a-f0-9]{8}") + '-' + | ||
| faker.regexify("[a-f0-9]{4}") + '-' + | ||
| faker.regexify("[a-f0-9]{4}") + '-' + | ||
| faker.regexify("[a-f0-9]{4}") + '-' + | ||
| faker.regexify("[a-f0-9]{12}"); | ||
| } | ||
|
|
||
| public String tenantId() { | ||
| return subscriptionId(); | ||
| } | ||
| public String resourceGroup() { | ||
| return "rg-" + randHex(); | ||
| } | ||
|
|
||
| public String managementGroup() { | ||
| return "mg-" + randHex(); | ||
| } | ||
|
|
||
| public String applicationGateway() { | ||
| return "agw-" + randHex(); | ||
| } | ||
|
|
||
| public String bastionHost() { | ||
| return "bas-" + randHex(); | ||
| } | ||
|
|
||
| public String firewall() { | ||
| return "afw-" + randHex(); | ||
| } | ||
|
|
||
| public String loadBalancer() { | ||
| return "lbi-" + randHex(); | ||
| } | ||
|
|
||
| public String networkSecurityGroup() { | ||
| return "nsg-" + randHex(); | ||
| } | ||
|
|
||
| public String virtualNetwork() { | ||
| return "vnet-" + randHex(); | ||
| } | ||
|
|
||
| public String virtualWan() { | ||
| return "vwan-" + randHex(); | ||
| } | ||
|
|
||
| public String appServiceEnvironment() { | ||
| return "ase-" + randHex(); | ||
| } | ||
|
|
||
| public String appServicePlan() { | ||
| return "asp-" + randHex(); | ||
| } | ||
|
|
||
| public String loadTesting() { | ||
| return "lt-" + randHex(); | ||
| } | ||
|
|
||
| public String staticWebApp() { | ||
| return "stapp-" + randHex(); | ||
| } | ||
|
|
||
| public String virtualMachine() { | ||
| return "vm-" + randHex(); | ||
| } | ||
|
|
||
| public String storageAccount() { | ||
| return "st-" + randHex(); | ||
| } | ||
|
|
||
| public String containerRegistry() { | ||
| return "cr-" + randHex(); | ||
| } | ||
|
|
||
| public String containerApps() { | ||
| return "ca-" + randHex(); | ||
| } | ||
|
|
||
| public String containerAppsEnvironment() { | ||
| return "cae-" + randHex(); | ||
| } | ||
|
|
||
| public String containerInstance() { | ||
| return "ci-" + randHex(); | ||
| } | ||
|
|
||
| public String cosmosDBDatabase() { | ||
| return "cosmos-" + randHex(); | ||
| } | ||
|
|
||
| public String sqlDatabase() { | ||
| return "sql-" + randHex(); | ||
| } | ||
|
|
||
| public String mysqlDatabase() { | ||
| return "mysql-" + randHex(); | ||
| } | ||
|
|
||
| public String postgreSQLDatabase() { | ||
| return "psql-" + randHex(); | ||
| } | ||
|
|
||
| public String serviceBus() { | ||
| return "sb-" + randHex(); | ||
| } | ||
|
|
||
| public String serviceBusQueue() { | ||
| return "sbq-" + randHex(); | ||
| } | ||
|
|
||
| public String serviceBusTopic() { | ||
| return "sbt-" + randHex(); | ||
| } | ||
|
|
||
| public String keyVault() { | ||
| return "kv-" + randHex(); | ||
| } | ||
|
|
||
| public String logAnalytics() { | ||
| return "log-" + randHex(); | ||
| } | ||
|
|
||
| private String randHex() { | ||
| return faker.regexify("[a-f0-9]{16}"); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| en: | ||
| faker: | ||
| azure: | ||
| regions: [eastus, eastus2, southcentralus, westus2, westus3, australiaeast, southeastasia, northeurope, swedencentral, uksouth, westeurope, centralus, southafricanorth, centralindia, eastasia, japaneast, koreacentral, canadacentral, francecentral, germanywestcentral, norwayeast, switzerlandnorth, uaenorth, brazilsouth, eastus2euap, qatarcentral, centralusstage, eastusstage, eastus2stage, northcentralusstage, southcentralusstage, westusstage, westus2stage, asia, asiapacific, australia, brazil, canada, europe, france, germany, global, india, japan, korea, norway, singapore, southafrica, switzerland, uae, uk, unitedstates, unitedstateseuap, eastasiastage, southeastasiastage, eastusstg, southcentralusstg, northcentralus, westus, jioindiawest, centraluseuap, westcentralus, southafricawest, australiacentral, australiacentral2, australiasoutheast, japanwest, jioindiacentral, koreasouth, southindia, westindia, canadaeast, francesouth, germanynorth, norwaywest, switzerlandwest, ukwest, uaecentral, brazilsoutheast] |
164 changes: 164 additions & 0 deletions
164
src/test/java/net/datafaker/providers/base/AzureTest.java
This file contains hidden or 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,164 @@ | ||
| package net.datafaker.providers.base; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class AzureTest extends BaseFakerTest<BaseFaker> { | ||
|
|
||
| @Test | ||
| void testRegion() { | ||
| String region = faker.azure().region(); | ||
| assertThat(region).matches("(eastus|eastus2|southcentralus|westus2|westus3|australiaeast|southeastasia|northeurope|swedencentral|uksouth|westeurope|centralus|southafricanorth|centralindia|eastasia|japaneast|koreacentral|canadacentral|francecentral|germanywestcentral|norwayeast|switzerlandnorth|uaenorth|brazilsouth|eastus2euap|qatarcentral|centralusstage|eastusstage|eastus2stage|northcentralusstage|southcentralusstage|westusstage|westus2stage|asia|asiapacific|australia|brazil|canada|europe|france|germany|global|india|japan|korea|norway|singapore|southafrica|switzerland|uae|uk|unitedstates|unitedstateseuap|eastasiastage|southeastasiastage|eastusstg|southcentralusstg|northcentralus|westus|jioindiawest|centraluseuap|westcentralus|southafricawest|australiacentral|australiacentral2|australiasoutheast|japanwest|jioindiacentral|koreasouth|southindia|westindia|canadaeast|francesouth|germanynorth|norwaywest|switzerlandwest|ukwest|uaecentral|brazilsoutheast)"); | ||
| } | ||
|
|
||
| @Test | ||
| void testAccountId() { | ||
| assertThat(faker.azure().subscriptionId()).matches("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"); | ||
| } | ||
|
|
||
| @Test | ||
| void testTenantId() { | ||
| assertThat(faker.azure().tenantId()).matches("[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"); | ||
| } | ||
|
|
||
| @Test | ||
| void testResourceGroup() { | ||
| assertThat(faker.azure().resourceGroup()).matches("^rg-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testManagementGroup() { | ||
| assertThat(faker.azure().managementGroup()).matches("^mg-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testApplicationGateway() { | ||
| assertThat(faker.azure().applicationGateway()).matches("^agw-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testBastionHost() { | ||
| assertThat(faker.azure().bastionHost()).matches("^bas-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testFirewall() { | ||
| assertThat(faker.azure().firewall()).matches("^afw-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testLoadBalancer() { | ||
| assertThat(faker.azure().loadBalancer()).matches("^lbi-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testNetworkSecurityGroup() { | ||
| assertThat(faker.azure().networkSecurityGroup()).matches("^nsg-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testVirtualNetwork() { | ||
| assertThat(faker.azure().virtualNetwork()).matches("^vnet-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testVirtualWan() { | ||
| assertThat(faker.azure().virtualWan()).matches("^vwan-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testAppServiceEnvironment() { | ||
| assertThat(faker.azure().appServiceEnvironment()).matches("^ase-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testAppServicePlan() { | ||
| assertThat(faker.azure().appServicePlan()).matches("^asp-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testLoadTesting() { | ||
| assertThat(faker.azure().loadTesting()).matches("^lt-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testStaticWebApp() { | ||
| assertThat(faker.azure().staticWebApp()).matches("^stapp-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testVirtualMachine() { | ||
| assertThat(faker.azure().virtualMachine()).matches("^vm-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testStorageAccount() { | ||
| assertThat(faker.azure().storageAccount()).matches("^st-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testContainerRegistry() { | ||
| assertThat(faker.azure().containerRegistry()).matches("^cr-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testContainerApps() { | ||
| assertThat(faker.azure().containerApps()).matches("^ca-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testContainerAppsEnvironment() { | ||
| assertThat(faker.azure().containerAppsEnvironment()).matches("^cae-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testContainerInstance() { | ||
| assertThat(faker.azure().containerInstance()).matches("^ci-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testCosmosDBDatabase() { | ||
| assertThat(faker.azure().cosmosDBDatabase()).matches("^cosmos-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testSqlDatabase() { | ||
| assertThat(faker.azure().sqlDatabase()).matches("^sql-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testMysqlDatabase() { | ||
| assertThat(faker.azure().mysqlDatabase()).matches("^mysql-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testPostgreSQLDatabase() { | ||
| assertThat(faker.azure().postgreSQLDatabase()).matches("^psql-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testServiceBus() { | ||
| assertThat(faker.azure().serviceBus()).matches("^sb-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testServiceBusQueue() { | ||
| assertThat(faker.azure().serviceBusQueue()).matches("^sbq-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testServiceBusTopic() { | ||
| assertThat(faker.azure().serviceBusTopic()).matches("^sbt-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testKeyVault() { | ||
| assertThat(faker.azure().keyVault()).matches("^kv-[0-9a-f]{16}$"); | ||
| } | ||
|
|
||
| @Test | ||
| void testLogAnalytics() { | ||
| assertThat(faker.azure().logAnalytics()).matches("^log-[0-9a-f]{16}$"); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small mistake here, I think you used IntelliJ to autofix the urls? (I had a similar issue.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Intellij :o) Thanks for fixing it