handle empty onboard to avoid breaking clients and dashboard

This commit is contained in:
Maycon Santos
2025-07-02 01:38:40 +02:00
parent 7a5edb3894
commit d806fc4a03
5 changed files with 101 additions and 58 deletions

View File

@@ -61,9 +61,6 @@ func initAccountsTestData(t *testing.T, account *types.Account) *handler {
}, nil
},
UpdateAccountOnboardingFunc: func(ctx context.Context, accountID, userID string, onboarding *types.AccountOnboarding) (*types.AccountOnboarding, error) {
if onboarding == nil {
return nil, status.Errorf(status.InvalidArgument, "onboarding cannot be nil")
}
return &types.AccountOnboarding{
OnboardingFlowPending: true,
SignupFormPending: true,
@@ -194,13 +191,26 @@ func TestAccounts_AccountsHandler(t *testing.T) {
expectedID: accountID,
},
{
name: "PutAccount fail without onboarding",
name: "PutAccount OK without onboarding",
expectedBody: true,
requestType: http.MethodPut,
requestPath: "/api/accounts/" + accountID,
requestBody: bytes.NewBufferString("{\"settings\": {\"peer_login_expiration\": 15552000,\"peer_login_expiration_enabled\": false,\"jwt_groups_enabled\":true,\"jwt_groups_claim_name\":\"roles\",\"jwt_allow_groups\":[\"test\"],\"regular_users_view_blocked\":true}}"),
expectedStatus: http.StatusUnprocessableEntity,
expectedArray: false,
expectedStatus: http.StatusOK,
expectedSettings: api.AccountSettings{
PeerLoginExpiration: 15552000,
PeerLoginExpirationEnabled: false,
GroupsPropagationEnabled: br(false),
JwtGroupsClaimName: sr("roles"),
JwtGroupsEnabled: br(true),
JwtAllowGroups: &[]string{"test"},
RegularUsersViewBlocked: true,
RoutingPeerDnsResolutionEnabled: br(false),
LazyConnectionEnabled: br(false),
DnsDomain: sr(""),
},
expectedArray: false,
expectedID: accountID,
},
{
name: "Update account failure with high peer_login_expiration more than 180 days",