Skip to content

Commit 1f9bf58

Browse files
committed
feat(credentials): fixed testcases
1 parent e72bc32 commit 1f9bf58

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

internal/cmd/beta/alb/credentials/create/create.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ func outputResult(p *print.Printer, outputFormat string, item *alb.CreateCredent
169169
}
170170
p.Outputln(string(details))
171171
default:
172-
p.Outputf("Created credential %s\n",
173-
utils.PtrString(item.Credential.CredentialsRef),
174-
)
172+
if item.Credential != nil {
173+
p.Outputf("Created credential %s\n",
174+
utils.PtrString(item.Credential.CredentialsRef),
175+
)
176+
}
175177
}
176178
return nil
177179
}

internal/cmd/beta/alb/credentials/update/update.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const passwordEnv = "ALB_CREDENTIALS_PASSWORD" //nolint:gosec // false alert, th
2626
const (
2727
usernameFlag = "username"
2828
displaynameFlag = "displayname"
29-
passwordFlag = "password"
3029
credentialRefArg = "CREDENTIAL_REF_ARG" //nolint:gosec // false alert, these are not valid credentials
3130
)
3231

internal/cmd/beta/alb/credentials/update/update_test.go

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
88
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
9-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
109

1110
"github.com/google/go-cmp/cmp"
1211
"github.com/google/go-cmp/cmp/cmpopts"
@@ -34,7 +33,6 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
3433
globalflags.RegionFlag: testRegion,
3534
usernameFlag: testUsername,
3635
displaynameFlag: testDisplayname,
37-
passwordFlag: "true",
3836
}
3937
for _, mod := range mods {
4038
mod(flagValues)
@@ -52,7 +50,6 @@ func fixtureInputModel(mods ...func(model *inputModel)) inputModel {
5250
Username: &testUsername,
5351
Displayname: &testDisplayname,
5452
CredentialsRef: &testCredentialRef,
55-
Password: utils.Ptr(true),
5653
}
5754
for _, mod := range mods {
5855
mod(&model)
@@ -103,52 +100,23 @@ func TestParseInput(t *testing.T) {
103100
globalflags.ProjectIdFlag: testProjectId,
104101
globalflags.RegionFlag: testRegion,
105102
},
106-
isValid: true,
103+
isValid: false,
107104
expectedModel: fixtureInputModel(func(model *inputModel) {
108105
model.Username = nil
109-
model.Password = nil
110106
model.Displayname = nil
111107
}),
112108
},
113109
{
110+
description: "required values",
114111
args: []string{testCredentialRef},
115-
description: "only username",
116112
flagValues: map[string]string{
117113
globalflags.ProjectIdFlag: testProjectId,
118114
globalflags.RegionFlag: testRegion,
119115
usernameFlag: testUsername,
120-
},
121-
expectedModel: fixtureInputModel(func(model *inputModel) {
122-
model.Displayname = nil
123-
model.Password = nil
124-
}),
125-
isValid: true,
126-
}, {
127-
description: "only displayname",
128-
args: []string{testCredentialRef},
129-
flagValues: map[string]string{
130-
globalflags.ProjectIdFlag: testProjectId,
131-
globalflags.RegionFlag: testRegion,
132116
displaynameFlag: testDisplayname,
133117
},
134-
expectedModel: fixtureInputModel(func(model *inputModel) {
135-
model.Username = nil
136-
model.Password = nil
137-
}),
138-
isValid: true,
139-
}, {
140-
description: "only password",
141-
args: []string{testCredentialRef},
142-
flagValues: map[string]string{
143-
globalflags.ProjectIdFlag: testProjectId,
144-
globalflags.RegionFlag: testRegion,
145-
passwordFlag: "true",
146-
},
147-
expectedModel: fixtureInputModel(func(model *inputModel) {
148-
model.Username = nil
149-
model.Displayname = nil
150-
}),
151-
isValid: true,
118+
isValid: true,
119+
expectedModel: fixtureInputModel(),
152120
},
153121
}
154122

0 commit comments

Comments
 (0)