Skip to content

Commit

Permalink
Enable CMEK for azurerm_bot_service_azure_bot (#25418)
Browse files Browse the repository at this point in the history
* add support for CMEK on bot_service_resource

* update docs

* add deprecation notice on channel registration

* add test

* wait until role assignment is complete

* add note about SPN

* set role on Azure SPN for test

* disable test temp

* run correct test

* enable purge protection

* refactor test

* try using app registration for test

* parameterize name

* use different resoure for test

* fix ref

* try other prop again

* renable tests

* update note

* bump azuread provider for tests

* disable other tests

* refactor tests

* disable tests

* fmt

* data type is not a guid

* fix test

* let tests run concurrently

* fmt

* refactor more tests

* change validation

* refactor more tests

* make all tests visible

* remove sequential test file

* remove unused test resource

* replace sequential test with regular test

* refactor test

* use common test base

* Update internal/services/bot/bot_service_azure_bot_resource_test.go

Co-authored-by: kt <[email protected]>

* rename prop;

* formatting

* update docs

---------

Co-authored-by: kt <[email protected]>
  • Loading branch information
bruceharrison1984 and katbyte authored Mar 31, 2024
1 parent 548b691 commit 64ddeb4
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 252 deletions.
2 changes: 1 addition & 1 deletion internal/acceptance/testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (td TestData) providers() map[string]func() (*schema.Provider, error) {
func (td TestData) externalProviders() map[string]resource.ExternalProvider {
return map[string]resource.ExternalProvider{
"azuread": {
VersionConstraint: "=2.38.0",
VersionConstraint: "=2.47.0",
Source: "registry.terraform.io/hashicorp/azuread",
},
"time": {
Expand Down
12 changes: 6 additions & 6 deletions internal/services/bot/bot_channel_alexa_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (

type BotChannelAlexaResource struct{}

func testAccBotChannelAlexa_basic(t *testing.T) {
func TestAccBotChannelAlexa_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_alexa", "test")
r := BotChannelAlexaResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -35,11 +35,11 @@ func testAccBotChannelAlexa_basic(t *testing.T) {
})
}

func testAccBotChannelAlexa_requiresImport(t *testing.T) {
func TestAccBotChannelAlexa_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_alexa", "test")
r := BotChannelAlexaResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -50,11 +50,11 @@ func testAccBotChannelAlexa_requiresImport(t *testing.T) {
})
}

func testAccBotChannelAlexa_update(t *testing.T) {
func TestAccBotChannelAlexa_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_alexa", "test")
r := BotChannelAlexaResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (

type BotChannelDirectLineSpeechResource struct{}

func testAccBotChannelDirectLineSpeech_basic(t *testing.T) {
func TestAccBotChannelDirectLineSpeech_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_direct_line_speech", "test")
r := BotChannelDirectLineSpeechResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.cognitiveAccount(data),
},
Expand All @@ -39,11 +39,11 @@ func testAccBotChannelDirectLineSpeech_basic(t *testing.T) {
})
}

func testAccBotChannelDirectLineSpeech_requiresImport(t *testing.T) {
func TestAccBotChannelDirectLineSpeech_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_direct_line_speech", "test")
r := BotChannelDirectLineSpeechResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.cognitiveAccount(data),
},
Expand All @@ -58,11 +58,11 @@ func testAccBotChannelDirectLineSpeech_requiresImport(t *testing.T) {
})
}

func testAccBotChannelDirectLineSpeech_complete(t *testing.T) {
func TestAccBotChannelDirectLineSpeech_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_direct_line_speech", "test")
r := BotChannelDirectLineSpeechResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.cognitiveAccount(data),
},
Expand All @@ -77,11 +77,11 @@ func testAccBotChannelDirectLineSpeech_complete(t *testing.T) {
})
}

func testAccBotChannelDirectLineSpeech_update(t *testing.T) {
func TestAccBotChannelDirectLineSpeech_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_direct_line_speech", "test")
r := BotChannelDirectLineSpeechResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.cognitiveAccount(data),
},
Expand Down
12 changes: 6 additions & 6 deletions internal/services/bot/bot_channel_directline_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (

type BotChannelDirectlineResource struct{}

func testAccBotChannelDirectline_basic(t *testing.T) {
func TestAccBotChannelDirectline_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_directline", "test")
r := BotChannelDirectlineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -34,11 +34,11 @@ func testAccBotChannelDirectline_basic(t *testing.T) {
})
}

func testAccBotChannelDirectline_complete(t *testing.T) {
func TestAccBotChannelDirectline_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_directline", "test")
r := BotChannelDirectlineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.completeConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -49,11 +49,11 @@ func testAccBotChannelDirectline_complete(t *testing.T) {
})
}

func testAccBotChannelDirectline_update(t *testing.T) {
func TestAccBotChannelDirectline_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_directline", "test")
r := BotChannelDirectlineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
12 changes: 6 additions & 6 deletions internal/services/bot/bot_channel_email_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (

type BotChannelEmailResource struct{}

func testAccBotChannelEmail_basic(t *testing.T) {
func TestAccBotChannelEmail_basic(t *testing.T) {
if ok := skipEmailChannel(); ok {
t.Skip("Skipping as one of `ARM_TEST_EMAIL`, AND `ARM_TEST_EMAIL_PASSWORD` was not specified")
}
data := acceptance.BuildTestData(t, "azurerm_bot_channel_email", "test")
r := BotChannelEmailResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -38,14 +38,14 @@ func testAccBotChannelEmail_basic(t *testing.T) {
})
}

func testAccBotChannelEmail_update(t *testing.T) {
func TestAccBotChannelEmail_update(t *testing.T) {
if ok := skipEmailChannel(); ok {
t.Skip("Skipping as one of `ARM_TEST_EMAIL`, AND `ARM_TEST_EMAIL_PASSWORD` was not specified")
}
data := acceptance.BuildTestData(t, "azurerm_bot_channel_email", "test")
r := BotChannelEmailResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -63,15 +63,15 @@ func testAccBotChannelEmail_update(t *testing.T) {
})
}

func testAccBotChannelEmail_magicCode(t *testing.T) {
func TestAccBotChannelEmail_magicCode(t *testing.T) {
if os.Getenv("ARM_TEST_BOT_RESOURCE_GROUP_NAME") == "" || os.Getenv("ARM_TEST_BOT_NAME") == "" || os.Getenv("ARM_TEST_EMAIL") == "" || os.Getenv("ARM_TEST_MAGIC_CODE") == "" {
t.Skip("Skipping as one of `ARM_TEST_BOT_RESOURCE_GROUP_NAME`, `ARM_TEST_BOT_LOCATION`, `ARM_TEST_BOT_NAME`, `ARM_TEST_EMAIL`, AND `ARM_TEST_MAGIC_CODE` was not specified")
}

data := acceptance.BuildTestData(t, "azurerm_bot_channel_email", "test")
r := BotChannelEmailResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.magicCode(),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
12 changes: 6 additions & 6 deletions internal/services/bot/bot_channel_facebook_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

type BotChannelFacebookResource struct{}

func testAccBotChannelFacebook_basic(t *testing.T) {
func TestAccBotChannelFacebook_basic(t *testing.T) {
skipFacebookChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_facebook", "test")
r := BotChannelFacebookResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -37,13 +37,13 @@ func testAccBotChannelFacebook_basic(t *testing.T) {
})
}

func testAccBotChannelFacebook_requiresImport(t *testing.T) {
func TestAccBotChannelFacebook_requiresImport(t *testing.T) {
skipFacebookChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_facebook", "test")
r := BotChannelFacebookResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -54,13 +54,13 @@ func testAccBotChannelFacebook_requiresImport(t *testing.T) {
})
}

func testAccBotChannelFacebook_update(t *testing.T) {
func TestAccBotChannelFacebook_update(t *testing.T) {
skipFacebookChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_facebook", "test")
r := BotChannelFacebookResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
16 changes: 8 additions & 8 deletions internal/services/bot/bot_channel_line_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

type BotChannelLineResource struct{}

func testAccBotChannelLine_basic(t *testing.T) {
func TestAccBotChannelLine_basic(t *testing.T) {
skipLineChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_line", "test")
r := BotChannelLineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -37,13 +37,13 @@ func testAccBotChannelLine_basic(t *testing.T) {
})
}

func testAccBotChannelLine_requiresImport(t *testing.T) {
func TestAccBotChannelLine_requiresImport(t *testing.T) {
skipLineChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_line", "test")
r := BotChannelLineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -54,13 +54,13 @@ func testAccBotChannelLine_requiresImport(t *testing.T) {
})
}

func testAccBotChannelLine_complete(t *testing.T) {
func TestAccBotChannelLine_complete(t *testing.T) {
skipLineChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_line", "test")
r := BotChannelLineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -71,13 +71,13 @@ func testAccBotChannelLine_complete(t *testing.T) {
})
}

func testAccBotChannelLine_update(t *testing.T) {
func TestAccBotChannelLine_update(t *testing.T) {
skipLineChannel(t)

data := acceptance.BuildTestData(t, "azurerm_bot_channel_line", "test")
r := BotChannelLineResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
8 changes: 4 additions & 4 deletions internal/services/bot/bot_channel_ms_teams_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (

type BotChannelMsTeamsResource struct{}

func testAccBotChannelMsTeams_basic(t *testing.T) {
func TestAccBotChannelMsTeams_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_ms_teams", "test")
r := BotChannelMsTeamsResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -34,11 +34,11 @@ func testAccBotChannelMsTeams_basic(t *testing.T) {
})
}

func testAccBotChannelMsTeams_update(t *testing.T) {
func TestAccBotChannelMsTeams_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_bot_channel_ms_teams", "test")
r := BotChannelMsTeamsResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
12 changes: 6 additions & 6 deletions internal/services/bot/bot_channel_slack_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (

type BotChannelSlackResource struct{}

func testAccBotChannelSlack_basic(t *testing.T) {
func TestAccBotChannelSlack_basic(t *testing.T) {
if ok := skipSlackChannel(); ok {
t.Skip("Skipping as one of `ARM_TEST_SLACK_CLIENT_ID`, `ARM_TEST_SLACK_CLIENT_SECRET`, or `ARM_TEST_SLACK_VERIFICATION_TOKEN` was not specified")
}
data := acceptance.BuildTestData(t, "azurerm_bot_channel_slack", "test")
r := BotChannelSlackResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -38,14 +38,14 @@ func testAccBotChannelSlack_basic(t *testing.T) {
})
}

func testAccBotChannelSlack_complete(t *testing.T) {
func TestAccBotChannelSlack_complete(t *testing.T) {
if ok := skipSlackChannel(); ok {
t.Skip("Skipping as one of `ARM_TEST_SLACK_CLIENT_ID`, `ARM_TEST_SLACK_CLIENT_SECRET`, `ARM_TEST_SLACK_VERIFICATION_TOKEN`, `ARM_TEST_SLACK_SIGNING_SECRET` was not specified")
}
data := acceptance.BuildTestData(t, "azurerm_bot_channel_slack", "test")
r := BotChannelSlackResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -56,14 +56,14 @@ func testAccBotChannelSlack_complete(t *testing.T) {
})
}

func testAccBotChannelSlack_update(t *testing.T) {
func TestAccBotChannelSlack_update(t *testing.T) {
if ok := skipSlackChannel(); ok {
t.Skip("Skipping as one of `ARM_TEST_SLACK_CLIENT_ID`, `ARM_TEST_SLACK_CLIENT_SECRET`, or `ARM_TEST_SLACK_VERIFICATION_TOKEN` was not specified")
}
data := acceptance.BuildTestData(t, "azurerm_bot_channel_slack", "test")
r := BotChannelSlackResource{}

data.ResourceSequentialTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicConfig(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down
Loading

0 comments on commit 64ddeb4

Please sign in to comment.