package serverruntime

import (
	"context"

	"github.com/pingcap-inc/nexuscrm-api-host/hostruntime"
)

type routeTestWebSocketAuthorizationFactory struct{}

type routeTestWebSocketAuthorizationLease struct {
	state hostruntime.AuthorizingPermissionState
}

func (routeTestWebSocketAuthorizationFactory) OpenWebSocketAuthorization(
	_ context.Context,
	_ string,
	initial hostruntime.AuthorizingPermissionState,
) (hostruntime.WebSocketAuthorizationLease, error) {
	return routeTestWebSocketAuthorizationLease{state: initial}, nil
}

func (lease routeTestWebSocketAuthorizationLease) ReauthorizeWebSocket(
	_ context.Context,
	_ hostruntime.WebSocketAuthorizationRequest,
) (hostruntime.AuthorizingPermissionState, error) {
	return lease.state, nil
}
