@@ -17,6 +17,7 @@ var testRSAPubKey string = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCi+ErxScCKIVqg
17
17
var testRSAPubKeyUpdatedComment string = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCi+ErxScCKIVqg2ZRJ6Mx2Yd/RTsh2DGyhUR8z8Iey4rpi1YOBlpTgjxxnSLy26J++Un/iWYDP8wMvEjXElkWz3z4I+Z3mfF3dv039FTCu+O17Mw20Ek4DJxdrKvOgul040sUG/ABVHo6DjqjokjoVJwzUrUmoOtbeMMD8hFN9bWdEVyTj18XQO8nvEe/VkbhCRhAlZC1l60fM07/7Tw83SV5UNAnBtOB+nfa3b24baO+Ijc4+PqYcBuUAF6DvhXW2gZPqf5wjDBJqlDlRTYDdHarMXZAKBpWfWj0gntbtEOM+Fnp6hS1HajaeveNSs6yQwgQEDN2boQnDuvXJ8Y7zW3YQKZp8z0uqWYJSIrYRKVEVYL7gDWL9NvdRV52d/RKPnE/BlL2chiAWBRCT8buQdjVtEPPoYbA1667PXZg6PI9yhCGEIjCj71XzPssA6VL/R7yUafsmNLsirWz9Uyh3HJWCcgNuO9mglP5nfFHIXSHQVhEUEYMfzv1iX5FrenU= [email protected] "
18
18
var updatedRSAPubKey string = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDStVqW58VZ5afXFphIvu2JahndXslJZMkgWsNiYCNdk/NvrEbc4i7yZVoDPFQsbS9I6Ty1RMW7qy3KxJalMsVHcw8arCQFDxs/ka1NHGCUPl68t5ZxUOl900KRQ0lOzGnDQMqG/UUZdPw4CCmigTr6Z9ZBcD1fXAiUwbXR4tWrr5z9KWXC2HgF4WkIJUTIct7ilY1m9W0y79dI/+K8bZrurn3q2QK83pxqqWkLwvUsCxtlhMpwuyflyzyuz8xPZl2GlZgxeIpr68gsPHIzzWizibwFfbRYKCZO4wD0r7JCDOYs9KjcIPpCG6d3HUqijClgdQSBnLwHTdE04ZtdzO8akvy0hMzRCooI5TSc8IAHos53Gp9aaW92sPA8za+WRP6OSH6UsOW4N+iQc4jyl7/fckMSgIZlJouNqqV+P8iqIFJGs70Tj5L8G/m+P2lc3kcE4Vjmj+Fc0xG5+I/PsSOpcc6DfDfZdVDRe8yklYd/qC1jI89OCeqjxu3XcUGHj9s= [email protected] "
19
19
var updatedRSAPubKeyWithoutComment string = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDStVqW58VZ5afXFphIvu2JahndXslJZMkgWsNiYCNdk/NvrEbc4i7yZVoDPFQsbS9I6Ty1RMW7qy3KxJalMsVHcw8arCQFDxs/ka1NHGCUPl68t5ZxUOl900KRQ0lOzGnDQMqG/UUZdPw4CCmigTr6Z9ZBcD1fXAiUwbXR4tWrr5z9KWXC2HgF4WkIJUTIct7ilY1m9W0y79dI/+K8bZrurn3q2QK83pxqqWkLwvUsCxtlhMpwuyflyzyuz8xPZl2GlZgxeIpr68gsPHIzzWizibwFfbRYKCZO4wD0r7JCDOYs9KjcIPpCG6d3HUqijClgdQSBnLwHTdE04ZtdzO8akvy0hMzRCooI5TSc8IAHos53Gp9aaW92sPA8za+WRP6OSH6UsOW4N+iQc4jyl7/fckMSgIZlJouNqqV+P8iqIFJGs70Tj5L8G/m+P2lc3kcE4Vjmj+Fc0xG5+I/PsSOpcc6DfDfZdVDRe8yklYd/qC1jI89OCeqjxu3XcUGHj9s="
20
+ var testKeyWithTrailingNewline string = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMG5+BWfNRCNE9chUUooEwS/QeNMN5Z1RBdY1GQ0VqMa\n "
20
21
21
22
func TestAccGitlabUserSSHKey_basic (t * testing.T ) {
22
23
var key gitlab.SSHKey
@@ -79,6 +80,48 @@ func TestAccGitlabUserSSHKey_basic(t *testing.T) {
79
80
})
80
81
}
81
82
83
+ func TestAccGitlabUserSSHKey_ignoreTrailingWhitespaces (t * testing.T ) {
84
+ testUser := testAccCreateUsers (t , 1 )[0 ]
85
+
86
+ resource .ParallelTest (t , resource.TestCase {
87
+ ProviderFactories : providerFactories ,
88
+ CheckDestroy : testAccCheckGitlabUserSSHKeyDestroy ,
89
+ Steps : []resource.TestStep {
90
+ // Create a user + sshkey
91
+ {
92
+ Config : fmt .Sprintf (`
93
+ resource "gitlab_user_sshkey" "this" {
94
+ user_id = %d
95
+ title = "test"
96
+ key = <<EOF
97
+ %s
98
+ EOF
99
+ }
100
+ ` , testUser .ID , testKeyWithTrailingNewline ),
101
+ },
102
+ // Check for no-op plan
103
+ {
104
+ Config : fmt .Sprintf (`
105
+ resource "gitlab_user_sshkey" "this" {
106
+ user_id = %d
107
+ title = "test"
108
+ key = <<EOF
109
+ %s
110
+ EOF
111
+ }
112
+ ` , testUser .ID , testKeyWithTrailingNewline ),
113
+ PlanOnly : true ,
114
+ },
115
+ // Verify Import
116
+ {
117
+ ResourceName : "gitlab_user_sshkey.this" ,
118
+ ImportState : true ,
119
+ ImportStateVerify : true ,
120
+ },
121
+ },
122
+ })
123
+ }
124
+
82
125
func testAccCheckGitlabUserSSHKeyDestroy (s * terraform.State ) error {
83
126
for _ , rs := range s .RootModule ().Resources {
84
127
if rs .Type != "gitlab_user_sshkey" {
0 commit comments