Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Hotfix v1.17.4 2052 (#2053)
Browse files Browse the repository at this point in the history
* Handle same customer and account external tenants ID

* Update values.yaml

* Adjust test

* Formatting
  • Loading branch information
dzahariev authored Oct 5, 2021
1 parent 3086178 commit afeaa49
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ global:
version: "PR-2027"
director:
dir:
version: "PR-2049"
version: "PR-2053"
gateway:
dir:
version: "PR-2027"
Expand Down Expand Up @@ -104,7 +104,7 @@ global:
version: "PR-44"
e2e_tests:
dir:
version: "PR-2027"
version: "PR-2053"
isLocalEnv: false
oauth2:
host: oauth2
Expand Down
4 changes: 4 additions & 0 deletions components/director/internal/tenantfetchersvc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func (h *handler) getSubscriptionRequest(body []byte, region string) (*TenantSub
req.SubaccountTenantID = ""
}

if req.AccountTenantID == req.CustomerTenantID {
req.CustomerTenantID = ""
}

return req, nil
}

Expand Down
22 changes: 21 additions & 1 deletion components/director/internal/tenantfetchersvc/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ func TestService_Create(t *testing.T) {
})
assert.NoError(t, err)

bodyWithMathcingParent, err := json.Marshal(tenantCreationRequest{
TenantID: tenantExtID,
CustomerID: tenantExtID,
Subdomain: tenantSubdomain,
SubscriptionProviderID: subscriptionProviderID,
})
assert.NoError(t, err)

bodyWithMissingTenantSubdomain, err := json.Marshal(tenantCreationRequest{
TenantID: tenantExtID,
CustomerID: parentTenantExtID,
Expand Down Expand Up @@ -151,7 +159,7 @@ func TestService_Create(t *testing.T) {
ExpectedStatusCode: http.StatusOK,
},
{
Name: "Succeeds when matching child tenant ID is provided",
Name: "Succeeds when matching subaccount and account tenant IDs are provided",
TxFn: txGen.ThatSucceeds,
TenantSubscriberFn: func() *automock.TenantSubscriber {
subscriber := &automock.TenantSubscriber{}
Expand All @@ -162,6 +170,18 @@ func TestService_Create(t *testing.T) {
ExpectedSuccessOutput: compassURL,
ExpectedStatusCode: http.StatusOK,
},
{
Name: "Succeeds when matching customer and account tenant IDs are provided",
TxFn: txGen.ThatSucceeds,
TenantSubscriberFn: func() *automock.TenantSubscriber {
subscriber := &automock.TenantSubscriber{}
subscriber.On("Subscribe", txtest.CtxWithDBMatcher(), &accountWithoutParentProvisioningRequest, "").Return(nil).Once()
return subscriber
},
Request: httptest.NewRequest(http.MethodPut, target, bytes.NewBuffer(bodyWithMathcingParent)),
ExpectedSuccessOutput: compassURL,
ExpectedStatusCode: http.StatusOK,
},
{
Name: "Returns error when reading request body fails",
TxFn: txGen.ThatDoesntStartTransaction,
Expand Down
18 changes: 18 additions & 0 deletions tests/tenant-fetcher/tests/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ func TestOnboardingHandler(t *testing.T) {
assertTenant(t, tnt, tenant.TenantID, tenant.Subdomain)
})

t.Run("Successful account tenant creation with matching customer and account tenant IDs", func(t *testing.T) {
id := uuid.New().String()
tenant := Tenant{
CustomerID: id,
TenantID: id,
Subdomain: defaultSubdomain,
SubscriptionProviderID: uuid.New().String(),
}

addTenantExpectStatusCode(t, tenant, http.StatusOK)

tnt, err := fixtures.GetTenantByExternalID(dexGraphQLClient, tenant.TenantID)
require.NoError(t, err)

// THEN
assertTenant(t, tnt, tenant.TenantID, tenant.Subdomain)
})

t.Run("Should not add already existing tenants", func(t *testing.T) {
tenantWithCustomer := Tenant{
TenantID: uuid.New().String(),
Expand Down

0 comments on commit afeaa49

Please sign in to comment.