From 18a71128af9d6635dbbedec7d7a158ff1c5a6636 Mon Sep 17 00:00:00 2001 From: Pratik Patel Date: Wed, 6 May 2026 16:57:55 -0700 Subject: [PATCH] fix(BRE2-931): make set case insensitive --- pkg/ssh/sshconfigurer_test.go | 2 +- pkg/store/organization.go | 2 +- pkg/store/organization_test.go | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pkg/ssh/sshconfigurer_test.go b/pkg/ssh/sshconfigurer_test.go index 56a7237dc..6f4975296 100644 --- a/pkg/ssh/sshconfigurer_test.go +++ b/pkg/ssh/sshconfigurer_test.go @@ -607,7 +607,7 @@ func TestSanitizeNodeName(t *testing.T) { want string }{ {"My GPU Box", "my-gpu-box"}, - {"pratik-ec2", "pratik-ec2"}, + {"my-ec2", "my-ec2"}, {"already-clean", "already-clean"}, {"UPPER CASE", "upper-case"}, {"special!@#chars", "special-chars"}, diff --git a/pkg/store/organization.go b/pkg/store/organization.go index 920f7efaa..764e32b34 100644 --- a/pkg/store/organization.go +++ b/pkg/store/organization.go @@ -123,7 +123,7 @@ func (s AuthHTTPStore) GetOrganizations(options *GetOrganizationsOptions) ([]ent filteredOrgs := []entity.Organization{} for _, o := range orgs { - if o.Name == options.Name { + if strings.EqualFold(o.Name, options.Name) { filteredOrgs = append(filteredOrgs, o) } } diff --git a/pkg/store/organization_test.go b/pkg/store/organization_test.go index c25566004..7a89b7943 100644 --- a/pkg/store/organization_test.go +++ b/pkg/store/organization_test.go @@ -50,6 +50,42 @@ func TestGetOrganizations(t *testing.T) { } } +func TestGetOrganizationsFiltersNameCaseInsensitive(t *testing.T) { + fs := MakeMockAuthHTTPStore() + httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient()) + defer httpmock.DeactivateAndReset() + + expected := []entity.Organization{{ + ID: "1", + Name: "TEST", + }} + orgs := []entity.Organization{ + expected[0], + { + ID: "2", + Name: "Other", + }, + } + res, err := httpmock.NewJsonResponder(200, orgs) + if !assert.Nil(t, err) { + return + } + url := fmt.Sprintf("%s/%s", fs.authHTTPClient.restyClient.BaseURL, orgPath) + httpmock.RegisterResponder("GET", url, res) + + org, err := fs.GetOrganizations(&GetOrganizationsOptions{Name: "test"}) + if !assert.Nil(t, err) { + return + } + if !assert.NotNil(t, org) { + return + } + + if !assert.Equal(t, expected, org) { + return + } +} + func TestCreateOrganization(t *testing.T) { fs := MakeMockAuthHTTPStore() httpmock.ActivateNonDefault(fs.authHTTPClient.restyClient.GetClient())