-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -84,6 +84,23 @@ func TestAcc_ResourceAccessOffer_ErrorWhenUsedWithJAAS(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAcc_ResourceAccessOffer_ErrorWhenUsedWithAdmin(t *testing.T) { | ||
SkipJAAS(t) | ||
|
||
modelNameAdminTest := acctest.RandomWithPrefix("tf-access-admin-model") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: frameworkProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ // Test username admin validation | ||
Config: testAccResourceAccessOfferAdminUser(modelNameAdminTest), | ||
ExpectError: regexp.MustCompile("user admin is not allowed.*"), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccResourceAccessOfferFixedUser() string { | ||
return ` | ||
resource "juju_access_offer" "test" { | ||
|
@@ -92,6 +109,35 @@ resource "juju_access_offer" "test" { | |
}` | ||
} | ||
|
||
func testAccResourceAccessOfferAdminUser(modelName string) string { | ||
return internaltesting.GetStringFromTemplateWithData("testAccResourceAccessOfferAdminUser", ` | ||
resource "juju_model" "{{.ModelName}}" { | ||
name = "{{.ModelName}}" | ||
} | ||
resource "juju_application" "appone" { | ||
name = "appone" | ||
model = juju_model.{{.ModelName}}.name | ||
charm { | ||
name = "juju-qa-dummy-source" | ||
base = "[email protected]" | ||
} | ||
} | ||
resource "juju_offer" "appone_endpoint" { | ||
model = juju_model.{{.ModelName}}.name | ||
application_name = juju_application.appone.name | ||
endpoint = "sink" | ||
} | ||
resource "juju_access_offer" "test" { | ||
offer_url = juju_offer.appone_endpoint.url | ||
admin = ["admin"] | ||
}`, internaltesting.TemplateData{ | ||
"ModelName": modelName}) | ||
} | ||
|
||
func testAccResourceAccessOffer(AdminUserName, ConsumeUserName, ReadUserName, OfferAdmin, OfferConsume, OfferRead, userPassword, modelName string) string { | ||
return internaltesting.GetStringFromTemplateWithData( | ||
"testAccResourceAccessOffer", | ||
|