diff --git a/README.md b/README.md index 219bd87e9..05ceb6b91 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,7 @@ Providers * Avatar * Aviation * AWS +* Azure * Babylon 5 * Back To The Future * Barcode diff --git a/src/main/java/net/datafaker/providers/base/Azure.java b/src/main/java/net/datafaker/providers/base/Azure.java new file mode 100644 index 000000000..d3367d25e --- /dev/null +++ b/src/main/java/net/datafaker/providers/base/Azure.java @@ -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: + * ... + * ... + * + * @since 1.7.0 + */ +public class Azure extends AbstractProvider { + + 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}"); + } +} diff --git a/src/main/java/net/datafaker/providers/base/BaseProviders.java b/src/main/java/net/datafaker/providers/base/BaseProviders.java index 2dee05dac..6a2bf3198 100644 --- a/src/main/java/net/datafaker/providers/base/BaseProviders.java +++ b/src/main/java/net/datafaker/providers/base/BaseProviders.java @@ -47,6 +47,10 @@ default Aws aws() { return getProvider(Aws.class, Aws::new); } + default Azure azure() { + return getProvider(Azure.class, Azure::new); + } + default Barcode barcode() { return getProvider(Barcode.class, Barcode::new); } diff --git a/src/main/java/net/datafaker/service/files/EnFile.java b/src/main/java/net/datafaker/service/files/EnFile.java index 7a9c8eb7d..eae58aadd 100644 --- a/src/main/java/net/datafaker/service/files/EnFile.java +++ b/src/main/java/net/datafaker/service/files/EnFile.java @@ -39,6 +39,7 @@ public String getPath() { "australia.yml", "aviation.yml", "aws.yml", + "azure.yml", "babylon5.yml", "back_to_the_future.yml", "barcode.yml", diff --git a/src/main/resources/en/azure.yml b/src/main/resources/en/azure.yml new file mode 100644 index 000000000..1e85c3f71 --- /dev/null +++ b/src/main/resources/en/azure.yml @@ -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] diff --git a/src/test/java/net/datafaker/providers/base/AzureTest.java b/src/test/java/net/datafaker/providers/base/AzureTest.java new file mode 100644 index 000000000..f84557752 --- /dev/null +++ b/src/test/java/net/datafaker/providers/base/AzureTest.java @@ -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 { + + @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}$"); + } +}