Skip to content

Commit 00f1517

Browse files
committed
fix(BRE2-931): make set case insensitive
1 parent aa0799e commit 00f1517

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

pkg/ssh/sshconfigurer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func TestSanitizeNodeName(t *testing.T) {
607607
want string
608608
}{
609609
{"My GPU Box", "my-gpu-box"},
610-
{"pratik-ec2", "pratik-ec2"},
610+
{"my-ec2", "my-ec2"},
611611
{"already-clean", "already-clean"},
612612
{"UPPER CASE", "upper-case"},
613613
{"special!@#chars", "special-chars"},

pkg/store/organization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (s AuthHTTPStore) GetOrganizations(options *GetOrganizationsOptions) ([]ent
123123

124124
filteredOrgs := []entity.Organization{}
125125
for _, o := range orgs {
126-
if o.Name == options.Name {
126+
if strings.EqualFold(o.Name, options.Name) {
127127
filteredOrgs = append(filteredOrgs, o)
128128
}
129129
}

pkg/store/organization_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,39 @@ func TestGetOrganizations(t *testing.T) {
5050
}
5151
}
5252

53+
func TestGetOrganizationsFiltersNameCaseInsensitive(t *testing.T) {
54+
fs := MakeMockAuthHTTPStore()
55+
httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient())
56+
defer httpmock.DeactivateAndReset()
57+
58+
expected := []entity.Organization{{
59+
ID: "1",
60+
Name: "TEST",
61+
}}
62+
orgs := append(expected, entity.Organization{
63+
ID: "2",
64+
Name: "Other",
65+
})
66+
res, err := httpmock.NewJsonResponder(200, orgs)
67+
if !assert.Nil(t, err) {
68+
return
69+
}
70+
url := fmt.Sprintf("%s/%s", fs.authHTTPClient.restyClient.BaseURL, orgPath)
71+
httpmock.RegisterResponder("GET", url, res)
72+
73+
org, err := fs.GetOrganizations(&GetOrganizationsOptions{Name: "test"})
74+
if !assert.Nil(t, err) {
75+
return
76+
}
77+
if !assert.NotNil(t, org) {
78+
return
79+
}
80+
81+
if !assert.Equal(t, expected, org) {
82+
return
83+
}
84+
}
85+
5386
func TestCreateOrganization(t *testing.T) {
5487
fs := MakeMockAuthHTTPStore()
5588
httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient())

0 commit comments

Comments
 (0)