Skip to content

Commit 7998e61

Browse files
authored
fix(BRE2-931): make set case insensitive (#385)
1 parent 1e5c17f commit 7998e61

3 files changed

Lines changed: 38 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
@@ -158,7 +158,7 @@ func (s AuthHTTPStore) GetOrganizations(options *GetOrganizationsOptions) ([]ent
158158

159159
filteredOrgs := []entity.Organization{}
160160
for _, o := range orgs {
161-
if o.Name == options.Name {
161+
if strings.EqualFold(o.Name, options.Name) {
162162
filteredOrgs = append(filteredOrgs, o)
163163
}
164164
}

pkg/store/organization_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,42 @@ func TestGetActiveOrganization_APIKeyUsesCredentialOrgNameWhenAvailable(t *testi
104104
assert.Equal(t, expected.Name, org.Name)
105105
}
106106

107+
func TestGetOrganizationsFiltersNameCaseInsensitive(t *testing.T) {
108+
fs := MakeMockAuthHTTPStore()
109+
httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient())
110+
defer httpmock.DeactivateAndReset()
111+
112+
expected := []entity.Organization{{
113+
ID: "1",
114+
Name: "TEST",
115+
}}
116+
orgs := []entity.Organization{
117+
expected[0],
118+
{
119+
ID: "2",
120+
Name: "Other",
121+
},
122+
}
123+
res, err := httpmock.NewJsonResponder(200, orgs)
124+
if !assert.Nil(t, err) {
125+
return
126+
}
127+
url := fmt.Sprintf("%s/%s", fs.authHTTPClient.restyClient.BaseURL, orgPath)
128+
httpmock.RegisterResponder("GET", url, res)
129+
130+
org, err := fs.GetOrganizations(&GetOrganizationsOptions{Name: "test"})
131+
if !assert.Nil(t, err) {
132+
return
133+
}
134+
if !assert.NotNil(t, org) {
135+
return
136+
}
137+
138+
if !assert.Equal(t, expected, org) {
139+
return
140+
}
141+
}
142+
107143
func TestCreateOrganization(t *testing.T) {
108144
fs := MakeMockAuthHTTPStore()
109145
httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient())

0 commit comments

Comments
 (0)