-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dli): add a new data source to get datasource authentication lis…
…t(4146)
- Loading branch information
1 parent
444fb8b
commit db902ae
Showing
4 changed files
with
445 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
subcategory: "Data Lake Insight (DLI)" | ||
--- | ||
|
||
# huaweicloud_dli_datasource_auths | ||
|
||
Use this data source to get the list of DLI datasource authentications within HuaweiCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "name" {} | ||
data "huaweicloud_dli_datasource_auths" "test" { | ||
name = var.name | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the data source. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `name` - (Optional, String) Specifies the name of the datasource authentication. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `auths` - The list of the datasource authentications. | ||
The [auths](#datasource_auths) structure is documented below. | ||
|
||
<a name="datasource_auths"></a> | ||
The `auths` block supports: | ||
|
||
* `name` - The name of the datasource authentication. | ||
|
||
* `type` - The type of the datasource authentication. | ||
|
||
* `username` - The login user name of the security cluster. | ||
|
||
* `certificate_location` - The OBS path of the security cluster certificate. | ||
|
||
* `truststore_location` - The OBS path of the **truststore** configuration file. | ||
|
||
* `keystore_location` - The OBS path of the **keystore** configuration file. | ||
|
||
* `keytab` - The OBS path of the **keytab** configuration file. | ||
|
||
* `krb5_conf` - The OBS path of the **krb5** configuration file. | ||
|
||
* `owner` - The user name of owner. | ||
|
||
* `created_at` - The creation time of the datasource authentication. | ||
|
||
* `updated_at` - The latest update time of the datasource authentication. |
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
199 changes: 199 additions & 0 deletions
199
huaweicloud/services/acceptance/dli/data_source_huaweicloud_dli_datasource_auths_test.go
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 |
---|---|---|
@@ -0,0 +1,199 @@ | ||
package dli | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDatasourceAuths_basic(t *testing.T) { | ||
var ( | ||
name = acceptance.RandomAccResourceName() | ||
password = acceptance.RandomPassword() | ||
byName = "data.huaweicloud_dli_datasource_auths.filter_by_name" | ||
dcByName = acceptance.InitDataSourceCheck(byName) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.TestAccPreCheck(t) }, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDatasourceAuths_basic(name, password), | ||
Check: resource.ComposeTestCheckFunc( | ||
dcByName.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(byName, "auths.#"), | ||
resource.TestCheckResourceAttrSet(byName, "auths.0.created_at"), | ||
resource.TestCheckResourceAttrSet(byName, "auths.0.updated_at"), | ||
resource.TestCheckResourceAttrSet(byName, "auths.0.owner"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.type", "passwd"), | ||
resource.TestCheckOutput("is_name_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDatasourceAuths_base(name string) string { | ||
return fmt.Sprintf(` | ||
data "huaweicloud_dli_datasource_auths" "filter_by_name" { | ||
depends_on = [ | ||
huaweicloud_dli_datasource_auth.test | ||
] | ||
name = "%[1]s" | ||
} | ||
output "is_name_filter_useful" { | ||
value = length(data.huaweicloud_dli_datasource_auths.filter_by_name.auths) == 1 | ||
} | ||
`, name) | ||
} | ||
|
||
func testDatasourceAuths_basic(name string, password string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_dli_datasource_auth" "test" { | ||
name = "%[1]s" | ||
type = "passwd" | ||
username = "%[1]s" | ||
password = "%[2]s" | ||
} | ||
%[3]s | ||
`, name, password, testDatasourceAuths_base(name)) | ||
} | ||
|
||
func TestAccDatasourceAuths_CSS(t *testing.T) { | ||
var ( | ||
name = acceptance.RandomAccResourceName() | ||
password = acceptance.RandomPassword() | ||
byName = "data.huaweicloud_dli_datasource_auths.filter_by_name" | ||
dcByName = acceptance.InitDataSourceCheck(byName) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckDliDsAuthCss(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDatasourceAuths_CSS(name, password), | ||
Check: resource.ComposeTestCheckFunc( | ||
dcByName.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(byName, "auths.#"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.type", "CSS"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.certificate_location", acceptance.HW_DLI_DS_AUTH_CSS_OBS_PATH), | ||
resource.TestCheckOutput("is_name_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDatasourceAuths_CSS(name string, password string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_dli_datasource_auth" "test" { | ||
name = "%[1]s" | ||
type = "CSS" | ||
username = "%[1]s" | ||
password = "%[2]s" | ||
certificate_location = "%[3]s" | ||
} | ||
%[4]s | ||
`, name, password, acceptance.HW_DLI_DS_AUTH_CSS_OBS_PATH, testDatasourceAuths_base(name)) | ||
} | ||
|
||
func TestAccDatasourceAuths_Kafka_SSL(t *testing.T) { | ||
var ( | ||
name = acceptance.RandomAccResourceName() | ||
password = acceptance.RandomPassword() | ||
byName = "data.huaweicloud_dli_datasource_auths.filter_by_name" | ||
dcByName = acceptance.InitDataSourceCheck(byName) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckDliDsAuthKafka(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDatasourceAuths_Kafka_SSL(name, password), | ||
Check: resource.ComposeTestCheckFunc( | ||
dcByName.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(byName, "auths.#"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.type", "Kafka_SSL"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.truststore_location", acceptance.HW_DLI_DS_AUTH_KAFKA_TRUST_OBS_PATH), | ||
resource.TestCheckResourceAttr(byName, "auths.0.keystore_location", acceptance.HW_DLI_DS_AUTH_KAFKA_KEY_OBS_PATH), | ||
resource.TestCheckOutput("is_name_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDatasourceAuths_Kafka_SSL(name string, password string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_dli_datasource_auth" "test" { | ||
name = "%[1]s" | ||
type = "Kafka_SSL" | ||
truststore_location = "%[3]s" | ||
truststore_password = "%[2]s" | ||
keystore_location = "%[4]s" | ||
keystore_password = "%[2]s" | ||
key_password = "%[2]s" | ||
} | ||
%[5]s | ||
`, name, password, acceptance.HW_DLI_DS_AUTH_KAFKA_TRUST_OBS_PATH, acceptance.HW_DLI_DS_AUTH_KAFKA_KEY_OBS_PATH, testDatasourceAuths_base(name)) | ||
} | ||
|
||
func TestAccDatasourceAuths_KRB(t *testing.T) { | ||
var ( | ||
name = acceptance.RandomAccResourceName() | ||
byName = "data.huaweicloud_dli_datasource_auths.filter_by_name" | ||
dcByName = acceptance.InitDataSourceCheck(byName) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckDliDsAuthKrb(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDatasourceAuths_KRB(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
dcByName.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(byName, "auths.#"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.type", "KRB"), | ||
resource.TestCheckResourceAttr(byName, "auths.0.krb5_conf", acceptance.HW_DLI_DS_AUTH_KRB_CONF_OBS_PATH), | ||
resource.TestCheckResourceAttr(byName, "auths.0.keytab", acceptance.HW_DLI_DS_AUTH_KRB_TAB_OBS_PATH), | ||
resource.TestCheckOutput("is_name_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDatasourceAuths_KRB(name string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_dli_datasource_auth" "test" { | ||
name = "%[1]s" | ||
type = "KRB" | ||
username = "%[1]s" | ||
krb5_conf = "%[2]s" | ||
keytab = "%[3]s" | ||
} | ||
%[4]s | ||
`, name, acceptance.HW_DLI_DS_AUTH_KRB_CONF_OBS_PATH, acceptance.HW_DLI_DS_AUTH_KRB_TAB_OBS_PATH, testDatasourceAuths_base(name)) | ||
} |
Oops, something went wrong.