Skip to content

Commit

Permalink
Add ManagedHSM endpoint and resource id (Azure#689)
Browse files Browse the repository at this point in the history
ref: https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates
ManagedHSM is only supported in AzurePublicCloud.

Signed-off-by: Anish Ramasekar <[email protected]>
  • Loading branch information
aramase committed Mar 30, 2022
1 parent b3899c1 commit 46c82ac
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
15 changes: 15 additions & 0 deletions autorest/azure/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ResourceIdentifier struct {
ServiceBus string `json:"serviceBus"`
SQLDatabase string `json:"sqlDatabase"`
CosmosDB string `json:"cosmosDB"`
ManagedHSM string `json:"managedHSM"`
}

// Environment represents a set of endpoints for each of Azure's Clouds.
Expand All @@ -63,6 +64,7 @@ type Environment struct {
ActiveDirectoryEndpoint string `json:"activeDirectoryEndpoint"`
GalleryEndpoint string `json:"galleryEndpoint"`
KeyVaultEndpoint string `json:"keyVaultEndpoint"`
ManagedHSMEndpoint string `json:"managedHSMEndpoint"`
GraphEndpoint string `json:"graphEndpoint"`
ServiceBusEndpoint string `json:"serviceBusEndpoint"`
BatchManagementEndpoint string `json:"batchManagementEndpoint"`
Expand All @@ -74,6 +76,7 @@ type Environment struct {
SQLDatabaseDNSSuffix string `json:"sqlDatabaseDNSSuffix"`
TrafficManagerDNSSuffix string `json:"trafficManagerDNSSuffix"`
KeyVaultDNSSuffix string `json:"keyVaultDNSSuffix"`
ManagedHSMDNSSuffix string `json:"managedHSMDNSSuffix"`
ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix"`
ServiceManagementVMDNSSuffix string `json:"serviceManagementVMDNSSuffix"`
ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix"`
Expand All @@ -95,6 +98,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.com/",
GalleryEndpoint: "https://gallery.azure.com/",
KeyVaultEndpoint: "https://vault.azure.net/",
ManagedHSMEndpoint: "https://managedhsm.azure.net/",
GraphEndpoint: "https://graph.windows.net/",
ServiceBusEndpoint: "https://servicebus.windows.net/",
BatchManagementEndpoint: "https://batch.core.windows.net/",
Expand All @@ -106,6 +110,7 @@ var (
SQLDatabaseDNSSuffix: "database.windows.net",
TrafficManagerDNSSuffix: "trafficmanager.net",
KeyVaultDNSSuffix: "vault.azure.net",
ManagedHSMDNSSuffix: "managedhsm.azure.net",
ServiceBusEndpointSuffix: "servicebus.windows.net",
ServiceManagementVMDNSSuffix: "cloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.azure.com",
Expand All @@ -125,6 +130,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.windows.net/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: "https://managedhsm.azure.net",
},
}

Expand All @@ -138,6 +144,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.us/",
GalleryEndpoint: "https://gallery.usgovcloudapi.net/",
KeyVaultEndpoint: "https://vault.usgovcloudapi.net/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.windows.net/",
ServiceBusEndpoint: "https://servicebus.usgovcloudapi.net/",
BatchManagementEndpoint: "https://batch.core.usgovcloudapi.net/",
Expand All @@ -149,6 +156,7 @@ var (
SQLDatabaseDNSSuffix: "database.usgovcloudapi.net",
TrafficManagerDNSSuffix: "usgovtrafficmanager.net",
KeyVaultDNSSuffix: "vault.usgovcloudapi.net",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.usgovcloudapi.net",
ServiceManagementVMDNSSuffix: "usgovcloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.usgovcloudapi.net",
Expand All @@ -168,6 +176,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.usgovcloudapi.net/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}

Expand All @@ -181,6 +190,7 @@ var (
ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/",
GalleryEndpoint: "https://gallery.chinacloudapi.cn/",
KeyVaultEndpoint: "https://vault.azure.cn/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.chinacloudapi.cn/",
ServiceBusEndpoint: "https://servicebus.chinacloudapi.cn/",
BatchManagementEndpoint: "https://batch.chinacloudapi.cn/",
Expand All @@ -192,6 +202,7 @@ var (
SQLDatabaseDNSSuffix: "database.chinacloudapi.cn",
TrafficManagerDNSSuffix: "trafficmanager.cn",
KeyVaultDNSSuffix: "vault.azure.cn",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.chinacloudapi.cn",
ServiceManagementVMDNSSuffix: "chinacloudapp.cn",
ResourceManagerVMDNSSuffix: "cloudapp.chinacloudapi.cn",
Expand All @@ -211,6 +222,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.chinacloudapi.cn/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}

Expand All @@ -224,6 +236,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.de/",
GalleryEndpoint: "https://gallery.cloudapi.de/",
KeyVaultEndpoint: "https://vault.microsoftazure.de/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.cloudapi.de/",
ServiceBusEndpoint: "https://servicebus.cloudapi.de/",
BatchManagementEndpoint: "https://batch.cloudapi.de/",
Expand All @@ -235,6 +248,7 @@ var (
SQLDatabaseDNSSuffix: "database.cloudapi.de",
TrafficManagerDNSSuffix: "azuretrafficmanager.de",
KeyVaultDNSSuffix: "vault.microsoftazure.de",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.cloudapi.de",
ServiceManagementVMDNSSuffix: "azurecloudapp.de",
ResourceManagerVMDNSSuffix: "cloudapp.microsoftazure.de",
Expand All @@ -254,6 +268,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.cloudapi.de/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}
)
Expand Down
18 changes: 17 additions & 1 deletion autorest/azure/environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
opInsightsResourceID = "--operational-insights-resource-id--"
ossRDBMSResourceID = "--oss-rdbms-resource-id--"
cosmosDBResourceID = "--cosmosdb-resource-id--"
managedHSMResourceID = "--managed-hsm-resource-id--"
)

// This correlates to the expected contents of ./testdata/test_environment_1.json
Expand All @@ -47,6 +48,7 @@ var testEnvironment1 = Environment{
ActiveDirectoryEndpoint: "--active-directory-endpoint--",
GalleryEndpoint: "--gallery-endpoint--",
KeyVaultEndpoint: "--key-vault--endpoint--",
ManagedHSMEndpoint: "--managed-hsm-endpoint--",
GraphEndpoint: "--graph-endpoint--",
StorageEndpointSuffix: "--storage-endpoint-suffix--",
CosmosDBDNSSuffix: "--cosmos-db-dns-suffix--",
Expand All @@ -56,6 +58,7 @@ var testEnvironment1 = Environment{
SQLDatabaseDNSSuffix: "--sql-database-dns-suffix--",
TrafficManagerDNSSuffix: "--traffic-manager-dns-suffix--",
KeyVaultDNSSuffix: "--key-vault-dns-suffix--",
ManagedHSMDNSSuffix: "--managed-hsm-dns-suffix--",
ServiceBusEndpointSuffix: "--service-bus-endpoint-suffix--",
ServiceManagementVMDNSSuffix: "--asm-vm-dns-suffix--",
ResourceManagerVMDNSSuffix: "--arm-vm-dns-suffix--",
Expand All @@ -69,6 +72,7 @@ var testEnvironment1 = Environment{
OperationalInsights: opInsightsResourceID,
OSSRDBMS: ossRDBMSResourceID,
CosmosDB: cosmosDBResourceID,
ManagedHSM: managedHSMResourceID,
},
}

Expand Down Expand Up @@ -207,6 +211,8 @@ func TestDeserializeEnvironment(t *testing.T) {
"serviceBusEndpoint": "--service-bus-endpoint--",
"keyVaultDNSSuffix": "--key-vault-dns-suffix--",
"keyVaultEndpoint": "--key-vault-endpoint--",
"managedHSMDNSSuffix": "--managed-hsm-dns-suffix--",
"managedHSMEndpoint": "--managed-hsm-endpoint--",
"managementPortalURL": "--management-portal-url--",
"publishSettingsURL": "--publish-settings-url--",
"resourceManagerEndpoint": "--resource-manager-endpoint--",
Expand All @@ -229,7 +235,8 @@ func TestDeserializeEnvironment(t *testing.T) {
"keyVault": "` + keyvaultResourceID + `",
"operationalInsights": "` + opInsightsResourceID + `",
"ossRDBMS": "` + ossRDBMSResourceID + `",
"cosmosDB": "` + cosmosDBResourceID + `"
"cosmosDB": "` + cosmosDBResourceID + `",
"managedHSM": "` + managedHSMResourceID + `"
}
}`

Expand Down Expand Up @@ -263,6 +270,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if "--key-vault-endpoint--" != testSubject.KeyVaultEndpoint {
t.Errorf("Expected KeyVaultEndpoint to be \"--key-vault-endpoint--\", but got %q", testSubject.KeyVaultEndpoint)
}
if "--managed-hsm-endpoint--" != testSubject.ManagedHSMEndpoint {
t.Errorf("Expected ManagedHSMEndpoint to be \"--managed-hsm-endpoint--\", but got %q", testSubject.ManagedHSMEndpoint)
}
if "--service-bus-endpoint--" != testSubject.ServiceBusEndpoint {
t.Errorf("Expected ServiceBusEndpoint to be \"--service-bus-endpoint--\", but goet %q", testSubject.ServiceBusEndpoint)
}
Expand Down Expand Up @@ -290,6 +300,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if "--key-vault-dns-suffix--" != testSubject.KeyVaultDNSSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--key-vault-dns-suffix--\", but got %q", testSubject.KeyVaultDNSSuffix)
}
if "--managed-hsm-dns-suffix--" != testSubject.ManagedHSMDNSSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--managed-hsm-dns-suffix--\", but got %q", testSubject.ManagedHSMDNSSuffix)
}
if "--service-bus-endpoint-suffix--" != testSubject.ServiceBusEndpointSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--service-bus-endpoint-suffix--\", but got %q", testSubject.ServiceBusEndpointSuffix)
}
Expand Down Expand Up @@ -323,6 +336,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if cosmosDBResourceID != testSubject.ResourceIdentifiers.CosmosDB {
t.Errorf("Expected ResourceIdentifiers.CosmosDB to be "+cosmosDBResourceID+", but got %q", testSubject.ResourceIdentifiers.CosmosDB)
}
if managedHSMResourceID != testSubject.ResourceIdentifiers.ManagedHSM {
t.Errorf("Expected ResourceIdentifiers.ManagedHSM to be "+managedHSMResourceID+", but got %q", testSubject.ResourceIdentifiers.ManagedHSM)
}
}

func TestRoundTripSerialization(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion autorest/azure/testdata/test_environment_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"activeDirectoryEndpoint": "--active-directory-endpoint--",
"galleryEndpoint": "--gallery-endpoint--",
"keyVaultEndpoint": "--key-vault--endpoint--",
"managedHSMEndpoint": "--managed-hsm-endpoint--",
"graphEndpoint": "--graph-endpoint--",
"storageEndpointSuffix": "--storage-endpoint-suffix--",
"cosmosDBDNSSuffix": "--cosmos-db-dns-suffix--",
Expand All @@ -16,6 +17,7 @@
"sqlDatabaseDNSSuffix": "--sql-database-dns-suffix--",
"trafficManagerDNSSuffix": "--traffic-manager-dns-suffix--",
"keyVaultDNSSuffix": "--key-vault-dns-suffix--",
"managedHSMDNSSuffix": "--managed-hsm-dns-suffix--",
"serviceBusEndpointSuffix": "--service-bus-endpoint-suffix--",
"serviceManagementVMDNSSuffix": "--asm-vm-dns-suffix--",
"resourceManagerVMDNSSuffix": "--arm-vm-dns-suffix--",
Expand All @@ -28,6 +30,8 @@
"keyVault": "--keyvault-resource-id--",
"operationalInsights": "--operational-insights-resource-id--",
"ossRDBMS": "--oss-rdbms-resource-id--",
"cosmosDB": "--cosmosdb-resource-id--"
"cosmosDB": "--cosmosdb-resource-id--",
"managedHSM": "--managed-hsm-resource-id--"
}
}

0 comments on commit 46c82ac

Please sign in to comment.