Skip to content

Commit

Permalink
Rename resource to azurerm_azuread_application and update function na…
Browse files Browse the repository at this point in the history
…mes to match.
  • Loading branch information
Xavier Gallardo committed May 29, 2018
1 parent 55c38d6 commit 598040b
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMAdApplication_importSimple(t *testing.T) {
resourceName := "azurerm_ad_application.test"
func TestAccAzureRMActiveDirectoryApplication_importSimple(t *testing.T) {
resourceName := "azurerm_azuread_application.test"

id := uuid.New().String()
config := testAccAzureRMAdApplication_simple(id)
config := testAccAzureRMActiveDirectoryApplication_simple(id)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAdApplicationDestroy,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Expand All @@ -31,16 +31,16 @@ func TestAccAzureRMAdApplication_importSimple(t *testing.T) {
})
}

func TestAccAzureRMAdApplication_importAdvanced(t *testing.T) {
resourceName := "azurerm_ad_application.test"
func TestAccAzureRMActiveDirectoryApplication_importAdvanced(t *testing.T) {
resourceName := "azurerm_azuread_application.test"

id := uuid.New().String()
config := testAccAzureRMAdApplication_advanced(id)
config := testAccAzureRMActiveDirectoryApplication_advanced(id)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAdApplicationDestroy,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Expand All @@ -54,17 +54,17 @@ func TestAccAzureRMAdApplication_importAdvanced(t *testing.T) {
})
}

func TestAccAzureRMAdApplication_importKeyCredential(t *testing.T) {
resourceName := "azurerm_ad_application.test"
func TestAccAzureRMActiveDirectoryApplication_importKeyCredential(t *testing.T) {
resourceName := "azurerm_azuread_application.test"

id := uuid.New().String()
keyId := uuid.New().String()
config := testAccAzureRMAdApplication_keyCredential_single(id, keyId, "AsymmetricX509Cert")
config := testAccAzureRMActiveDirectoryApplication_keyCredential_single(id, keyId, "AsymmetricX509Cert")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersWithTLS,
CheckDestroy: testCheckAzureRMAdApplicationDestroy,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Expand All @@ -78,19 +78,19 @@ func TestAccAzureRMAdApplication_importKeyCredential(t *testing.T) {
})
}

func TestAccAzureRMAdApplication_importPasswordCredential(t *testing.T) {
resourceName := "azurerm_ad_application.test"
func TestAccAzureRMActiveDirectoryApplication_importPasswordCredential(t *testing.T) {
resourceName := "azurerm_azuread_application.test"

id := uuid.New().String()
keyId := uuid.New().String()
timeStart := time.Now().UTC()
timeEnd := timeStart.Add(time.Duration(1) * time.Hour)
config := testAccAzureRMAdApplication_passwordCredential_single(id, keyId, timeStart, timeEnd)
config := testAccAzureRMActiveDirectoryApplication_passwordCredential_single(id, keyId, timeStart, timeEnd)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAdApplicationDestroy,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Expand Down
2 changes: 1 addition & 1 deletion azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"azurerm_ad_application": resourceArmAdApplication(),
"azurerm_azuread_application": resourceArmActiveDirectoryApplication(),
"azurerm_application_gateway": resourceArmApplicationGateway(),
"azurerm_application_insights": resourceArmApplicationInsights(),
"azurerm_application_security_group": resourceArmApplicationSecurityGroup(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func resourceArmAdApplication() *schema.Resource {
func resourceArmActiveDirectoryApplication() *schema.Resource {
return &schema.Resource{
Create: resourceArmAdApplicationCreate,
Read: resourceArmAdApplicationRead,
Update: resourceArmAdApplicationUpdate,
Delete: resourceArmAdApplicationDelete,
CustomizeDiff: customizeDiffAd,
Create: resourceArmActiveDirectoryApplicationCreate,
Read: resourceArmActiveDirectoryApplicationRead,
Update: resourceArmActiveDirectoryApplicationUpdate,
Delete: resourceArmActiveDirectoryApplicationDelete,
CustomizeDiff: customizeDiffActiveDirectoryApplication,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand Down Expand Up @@ -81,7 +81,7 @@ func resourceArmAdApplication() *schema.Resource {
}
}

func customizeDiffAd(diff *schema.ResourceDiff, v interface{}) error {
func customizeDiffActiveDirectoryApplication(diff *schema.ResourceDiff, v interface{}) error {

if err := customizeDiffKeyCredential(diff, v); err != nil {
return err
Expand All @@ -94,7 +94,7 @@ func customizeDiffAd(diff *schema.ResourceDiff, v interface{}) error {
return nil
}

func resourceArmAdApplicationCreate(d *schema.ResourceData, meta interface{}) error {
func resourceArmActiveDirectoryApplicationCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).applicationsClient
ctx := meta.(*ArmClient).StopContext

Expand All @@ -103,9 +103,9 @@ func resourceArmAdApplicationCreate(d *schema.ResourceData, meta interface{}) er

properties := graphrbac.ApplicationCreateParameters{
DisplayName: &name,
Homepage: expandAzureRmAdApplicationHomepage(d, name),
IdentifierUris: expandAzureRmAdApplicationIdentifierUris(d, name),
ReplyUrls: expandAzureRmAdApplicationReplyUrls(d, name),
Homepage: expandAzureRmActiveDirectoryApplicationHomepage(d, name),
IdentifierUris: expandAzureRmActiveDirectoryApplicationIdentifierUris(d, name),
ReplyUrls: expandAzureRmActiveDirectoryApplicationReplyUrls(d, name),
AvailableToOtherTenants: utils.Bool(multitenant),
}

Expand Down Expand Up @@ -136,22 +136,22 @@ func resourceArmAdApplicationCreate(d *schema.ResourceData, meta interface{}) er

d.SetId(*app.ObjectID)

return resourceArmAdApplicationRead(d, meta)
return resourceArmActiveDirectoryApplicationRead(d, meta)
}

func resourceArmAdApplicationRead(d *schema.ResourceData, meta interface{}) error {
func resourceArmActiveDirectoryApplicationRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).applicationsClient
ctx := meta.(*ArmClient).StopContext

resp, err := client.Get(ctx, d.Id())
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Application ID %q was not found - removing from state", d.Id())
log.Printf("[DEBUG] Azure AD Application ID %q was not found - removing from state", d.Id())
d.SetId("")
return nil
}

return fmt.Errorf("Error loading Application %q: %+v", d.Id(), err)
return fmt.Errorf("Error loading Azure AD Application %q: %+v", d.Id(), err)
}

d.Set("display_name", resp.DisplayName)
Expand All @@ -165,26 +165,26 @@ func resourceArmAdApplicationRead(d *schema.ResourceData, meta interface{}) erro

rkc, err := client.ListKeyCredentials(ctx, d.Id())
if err != nil {
return fmt.Errorf("Error loading Application Key Credentials %q: %+v", d.Id(), err)
return fmt.Errorf("Error loading Azure AD Application Key Credentials %q: %+v", d.Id(), err)
}

if err := d.Set("key_credential", flattenAzureRmKeyCredentials(rkc.Value)); err != nil {
return fmt.Errorf("[DEBUG] Error setting Application Key Credentials error: %#v", err)
return fmt.Errorf("[DEBUG] Error setting Azure AD Application Key Credentials error: %#v", err)
}

rpc, err := client.ListPasswordCredentials(ctx, d.Id())
if err != nil {
return fmt.Errorf("Error loading Application Password Credentials %q: %+v", d.Id(), err)
return fmt.Errorf("Error loading Azure AD Application Password Credentials %q: %+v", d.Id(), err)
}

if err := d.Set("password_credential", flattenAzureRmPasswordCredentials(rpc.Value)); err != nil {
return fmt.Errorf("[DEBUG] Error setting Application Password Credentials error: %#v", err)
return fmt.Errorf("[DEBUG] Error setting Azure AD Application Password Credentials error: %#v", err)
}

return nil
}

func resourceArmAdApplicationUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceArmActiveDirectoryApplicationUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).applicationsClient
ctx := meta.(*ArmClient).StopContext

Expand All @@ -197,15 +197,15 @@ func resourceArmAdApplicationUpdate(d *schema.ResourceData, meta interface{}) er
}

if d.HasChange("homepage") {
properties.Homepage = expandAzureRmAdApplicationHomepage(d, name)
properties.Homepage = expandAzureRmActiveDirectoryApplicationHomepage(d, name)
}

if d.HasChange("identifier_uris") {
properties.IdentifierUris = expandAzureRmAdApplicationIdentifierUris(d, name)
properties.IdentifierUris = expandAzureRmActiveDirectoryApplicationIdentifierUris(d, name)
}

if d.HasChange("reply_urls") {
properties.ReplyUrls = expandAzureRmAdApplicationReplyUrls(d, name)
properties.ReplyUrls = expandAzureRmActiveDirectoryApplicationReplyUrls(d, name)
}

if d.HasChange("available_to_other_tenants") {
Expand Down Expand Up @@ -276,10 +276,10 @@ func resourceArmAdApplicationUpdate(d *schema.ResourceData, meta interface{}) er

d.Partial(false)

return resourceArmAdApplicationRead(d, meta)
return resourceArmActiveDirectoryApplicationRead(d, meta)
}

func resourceArmAdApplicationDelete(d *schema.ResourceData, meta interface{}) error {
func resourceArmActiveDirectoryApplicationDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).applicationsClient
ctx := meta.(*ArmClient).StopContext

Expand All @@ -293,15 +293,15 @@ func resourceArmAdApplicationDelete(d *schema.ResourceData, meta interface{}) er
return nil
}

func expandAzureRmAdApplicationHomepage(d *schema.ResourceData, name string) *string {
func expandAzureRmActiveDirectoryApplicationHomepage(d *schema.ResourceData, name string) *string {
if v, ok := d.GetOk("homepage"); ok {
return utils.String(v.(string))
}

return utils.String(fmt.Sprintf("http://%s", name))
}

func expandAzureRmAdApplicationIdentifierUris(d *schema.ResourceData, name string) *[]string {
func expandAzureRmActiveDirectoryApplicationIdentifierUris(d *schema.ResourceData, name string) *[]string {
identifierUris := d.Get("identifier_uris").([]interface{})
identifiers := []string{}
for _, id := range identifierUris {
Expand All @@ -314,7 +314,7 @@ func expandAzureRmAdApplicationIdentifierUris(d *schema.ResourceData, name strin
return &identifiers
}

func expandAzureRmAdApplicationReplyUrls(d *schema.ResourceData, name string) *[]string {
func expandAzureRmActiveDirectoryApplicationReplyUrls(d *schema.ResourceData, name string) *[]string {
replyUrls := d.Get("reply_urls").([]interface{})
urls := []string{}
for _, url := range replyUrls {
Expand Down
Loading

0 comments on commit 598040b

Please sign in to comment.