Skip to content

Commit

Permalink
fix(ocm): use host instead of hostDomain for normalizing ocm providers
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade committed Sep 5, 2024
1 parent 2df3775 commit ee5f496
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/ocm/provider/authorizer/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func normalizeDomain(d string) (string, error) {
return "", err
}

return u.Hostname(), nil
return u.Host, nil
}

func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprovider.ProviderInfo, error) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/ocm/provider/authorizer/json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ func TestAuthorizer_GetInfoByDomain(t *testing.T) {
expectedDomain string
expectedError error
}{
"domain only": {givenDomain: "server-one:9200", expectedDomain: "server-one"},
"domain with port": {givenDomain: "server-two:9200", expectedDomain: "server-two:9200"},
"unknown domain": {givenDomain: "unknown-domain", expectedError: errtypes.NotFound("unknown-domain")},
"domain only": {givenDomain: "server-one", expectedDomain: "server-one"},
"domain with port": {givenDomain: "server-two:9200", expectedDomain: "server-two:9200"},
"domain only with port in result": {givenDomain: "server-two", expectedDomain: "server-two:9200"},
"unknown domain": {givenDomain: "unknown-domain", expectedError: errtypes.NotFound("unknown-domain")},
} {
t.Run(name, func(t *testing.T) {
info, err := authorizer.GetInfoByDomain(context.Background(), env.givenDomain)
Expand Down

0 comments on commit ee5f496

Please sign in to comment.