Merge branch 'main' of gitea.haiyihy.com:hy/hyapp-server
This commit is contained in:
commit
1e3d628f57
@ -62,7 +62,7 @@ var catalog = map[Code]Spec{
|
|||||||
RegionNotFound: spec(codes.NotFound, httpStatusNotFound, RegionNotFound, "not found"),
|
RegionNotFound: spec(codes.NotFound, httpStatusNotFound, RegionNotFound, "not found"),
|
||||||
RegionCountryConflict: spec(codes.FailedPrecondition, httpStatusConflict, RegionCountryConflict, "conflict"),
|
RegionCountryConflict: spec(codes.FailedPrecondition, httpStatusConflict, RegionCountryConflict, "conflict"),
|
||||||
RegionDisabled: spec(codes.FailedPrecondition, httpStatusConflict, RegionDisabled, "conflict"),
|
RegionDisabled: spec(codes.FailedPrecondition, httpStatusConflict, RegionDisabled, "conflict"),
|
||||||
InvalidInviteCode: spec(codes.InvalidArgument, httpStatusBadRequest, InvalidInviteCode, "invalid argument"),
|
InvalidInviteCode: spec(codes.InvalidArgument, httpStatusBadRequest, InvalidInviteCode, "invalid invite code"),
|
||||||
DeviceAlreadyRegistered: spec(
|
DeviceAlreadyRegistered: spec(
|
||||||
codes.FailedPrecondition,
|
codes.FailedPrecondition,
|
||||||
httpStatusConflict,
|
httpStatusConflict,
|
||||||
|
|||||||
@ -60,7 +60,7 @@ func TestCatalogMappings(t *testing.T) {
|
|||||||
grpcCode: codes.InvalidArgument,
|
grpcCode: codes.InvalidArgument,
|
||||||
httpStatus: httpStatusBadRequest,
|
httpStatus: httpStatusBadRequest,
|
||||||
publicCode: string(InvalidInviteCode),
|
publicCode: string(InvalidInviteCode),
|
||||||
publicMessage: "invalid argument",
|
publicMessage: "invalid invite code",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unavailable is exposed as upstream error",
|
name: "unavailable is exposed as upstream error",
|
||||||
|
|||||||
@ -8107,6 +8107,22 @@ func TestCompleteOnboardingAllowsIncompleteProfileAndUsesAuthenticatedUserID(t *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompleteOnboardingReturnsInvalidInviteCodeMessage(t *testing.T) {
|
||||||
|
profileClient := &fakeUserProfileClient{
|
||||||
|
completeErr: xerr.ToGRPCError(xerr.New(xerr.InvalidInviteCode, "invalid invite code")),
|
||||||
|
}
|
||||||
|
router := NewHandlerWithClients(&fakeRoomClient{}, nil, nil, profileClient).Routes(auth.NewVerifier("secret"))
|
||||||
|
body := []byte(`{"username":"hy","avatar":"https://cdn.example/a.png","gender":"male","country":"SG","invite_code":"BADCODE"}`)
|
||||||
|
request := httptest.NewRequest(http.MethodPost, "/api/v1/users/me/onboarding/complete", bytes.NewReader(body))
|
||||||
|
request.Header.Set("Authorization", "Bearer "+signGatewayTokenWithProfile(t, "secret", 42, false))
|
||||||
|
request.Header.Set("X-Request-ID", "req-onboarding-invalid-invite")
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
|
||||||
|
router.ServeHTTP(recorder, request)
|
||||||
|
|
||||||
|
assertEnvelopeMessage(t, recorder, http.StatusBadRequest, string(xerr.InvalidInviteCode), "invalid invite code", "req-onboarding-invalid-invite")
|
||||||
|
}
|
||||||
|
|
||||||
func TestProfileMutationEndpointsRequireCompletedProfileToken(t *testing.T) {
|
func TestProfileMutationEndpointsRequireCompletedProfileToken(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user