Skip to content

Commit

Permalink
Move subaccount expired (kyma-project#1192)
Browse files Browse the repository at this point in the history
* subaccount movement tests

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
ukff authored Sep 26, 2024
1 parent f52471b commit 0ff9143
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion cmd/broker/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const unsuspensionRequestBody = `{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "7d55d31d-35ae-4438-bf13-6ffdfa107d9f",
"context": {
"globalaccount_id": "global-account-id",
"subaccount_id": "subaccount-id",
"user_id": "john.smith@email.com",
"active": true
Expand Down
7 changes: 2 additions & 5 deletions internal/broker/instance_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ func (b *UpdateEndpoint) Update(_ context.Context, instanceID string, details do
}

if instance.IsExpired() {
if b.config.AllowUpdateExpiredInstanceWithContext {
newGlobalAccountId := ersContext.GlobalAccountID
if newGlobalAccountId != "" && (newGlobalAccountId != instance.GlobalAccountID) {
return domain.UpdateServiceSpec{}, nil
}
if b.config.AllowUpdateExpiredInstanceWithContext && ersContext.GlobalAccountID != "" {
return domain.UpdateServiceSpec{}, nil
}
return domain.UpdateServiceSpec{}, apiresponses.NewFailureResponse(fmt.Errorf("cannot update an expired instance"), http.StatusBadRequest, "")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/broker/instance_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ func TestUpdateExpiredInstance(t *testing.T) {
svc := NewUpdate(Config{AllowUpdateExpiredInstanceWithContext: true}, storage.Instances(), storage.RuntimeStates(), storage.Operations(), handler, true, false, true, queue, PlansConfig{},
planDefaults, logrus.New(), dashboardConfig, kcBuilder, &OneForAllConvergedCloudRegionsProvider{}, fakeKcpK8sClient)

t.Run("should reject change GA - it is same as previous", func(t *testing.T) {
t.Run("should accept if it is same as previous", func(t *testing.T) {
_, err = svc.Update(context.Background(), instanceID, domain.UpdateDetails{
ServiceID: KymaServiceID,
PlanID: TrialPlanID,
Expand All @@ -687,7 +687,7 @@ func TestUpdateExpiredInstance(t *testing.T) {
RawContext: json.RawMessage("{\"globalaccount_id\":\"globalaccount_id_init\"}"),
MaintenanceInfo: nil,
}, true)
require.Error(t, err)
require.NoError(t, err)
})

t.Run("should accept change GA", func(t *testing.T) {
Expand Down

0 comments on commit 0ff9143

Please sign in to comment.