Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 r/externalauth_kerberos: deprecate login_attribute argument #45

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changes/hotfix_external_auth_kerberos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- markdownlint-disable-file MD013 MD041 -->
BUG FIXES:

* **resource/wallix-bastion_externalauth_kerberos**: deprecate `login_attribute` argument (it produces Bad Request with API v3.12)
7 changes: 2 additions & 5 deletions bastion/resource_externalauth_kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type jsonExternalAuthKerberos struct {
Host string `json:"host"`
KerDomController string `json:"ker_dom_controller"`
KeyTab string `json:"keytab,omitempty"`
LoginAttribute string `json:"login_attribute"`
Type string `json:"type"`
}

Expand Down Expand Up @@ -69,6 +68,8 @@ func resourceExternalAuthKerberos() *schema.Resource {
"login_attribute": {
Type: schema.TypeString,
Optional: true,
Deprecated: "Remove this attribute's configuration as it is not used anymore" +
" and the attribute will be removed in the next major version of the provider.",
},
"use_primary_auth_domain": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -275,7 +276,6 @@ func prepareExternalAuthKerberosJSON(d *schema.ResourceData) jsonExternalAuthKer
Port: d.Get("port").(int),
Description: d.Get("description").(string),
KeyTab: d.Get("keytab").(string),
LoginAttribute: d.Get("login_attribute").(string),
UsePrimaryAuthDomain: d.Get("use_primary_auth_domain").(bool),
Type: "KERBEROS",
}
Expand Down Expand Up @@ -328,9 +328,6 @@ func fillExternalAuthKerberos(d *schema.ResourceData, jsonData jsonExternalAuthK
if tfErr := d.Set("description", jsonData.Description); tfErr != nil {
panic(tfErr)
}
if tfErr := d.Set("login_attribute", jsonData.LoginAttribute); tfErr != nil {
panic(tfErr)
}
if tfErr := d.Set("use_primary_auth_domain", jsonData.UsePrimaryAuthDomain); tfErr != nil {
panic(tfErr)
}
Expand Down
43 changes: 38 additions & 5 deletions bastion/resource_externalauth_kerberos_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// nolint: lll,nolintlint
package bastion_test

import (
Expand Down Expand Up @@ -33,12 +34,17 @@ func TestAccResourceExternalAuthKerberos_basic(t *testing.T) {
ImportState: true,
ImportStateId: "testacc_ExternalAuthKerberos",
},
{
Config: testAccResourceExternalAuthKerberosCreate2(),
},
{
Config: testAccResourceExternalAuthKerberosUpdate2(),
},
},
PreventPostDestroyRefresh: true,
})
}

// nolint: lll,nolintlint
func testAccResourceExternalAuthKerberosCreate() string {
k, _ := hex.DecodeString(keytabDataHexStr)
os.WriteFile("/tmp/testacc_data", k, 0644) //nolint: all
Expand All @@ -55,18 +61,45 @@ resource "wallix-bastion_externalauth_kerberos" "testacc_ExternalAuthKerberos" {
`
}

// nolint: lll,nolintlint
func testAccResourceExternalAuthKerberosUpdate() string {
return `
data "wallix-bastion_version" "v" {}
resource "wallix-bastion_externalauth_kerberos" "testacc_ExternalAuthKerberos" {
authentication_name = "testacc_ExternalAuthKerberos"
host = "server1"
ker_dom_controller = "EXAMPLE.COM"
port = 88
kerberos_password = true
port = 188
description = "testacc ExternalAuthKerberos"
login_attribute = "attribute"
use_primary_auth_domain = true
keytab = split(".", data.wallix-bastion_version.v.wab_version)[0] == "8" ? "" : filebase64("/tmp/testacc_data")
}
`
}

func testAccResourceExternalAuthKerberosCreate2() string {
return `
data "wallix-bastion_version" "v" {}
resource "wallix-bastion_externalauth_kerberos" "testacc_ExternalAuthKerberosPassword" {
authentication_name = "testacc_ExternalAuthKerberosPassword"
host = "server2"
ker_dom_controller = "EXAMPLE.COM"
kerberos_password = true
port = 88
keytab = split(".", data.wallix-bastion_version.v.wab_version)[0] == "8" ? "" : filebase64("/tmp/testacc_data")
}
`
}

func testAccResourceExternalAuthKerberosUpdate2() string {
return `
data "wallix-bastion_version" "v" {}
resource "wallix-bastion_externalauth_kerberos" "testacc_ExternalAuthKerberosPassword" {
authentication_name = "testacc_ExternalAuthKerberosPassword"
host = "server2"
ker_dom_controller = "EXAMPLE.COM"
kerberos_password = true
port = 188
description = "testacc ExternalAuthKerberosPassword"
use_primary_auth_domain = true
keytab = split(".", data.wallix-bastion_version.v.wab_version)[0] == "8" ? "" : filebase64("/tmp/testacc_data")
}
Expand Down
Loading