@Override
    protected Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
        return exchange.getPrincipal()
                .filter(OAuth2AuthenticationToken.class::isInstance)
                .cast(OAuth2AuthenticationToken.class)
                .flatMap(this::buildAuthorizedClient)
                .flatMap(client -> chain.execute(this.writeToken(exchange, client)));
    }
@Test
    public void havePrincipal() {
        OAuth2AccessToken accessToken = mock(OAuth2AccessToken.class);
        when(accessToken.getTokenValue()).thenReturn("token");
        ClientRegistration clientRegistration = ClientRegistration.withRegistrationId("registration_id")
                .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS).clientId("client_id")
                .tokenUri("token_uri").build();
        OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(clientRegistration, "shenyu", accessToken);
        
        when(oAuth2AuthorizedClientService.loadAuthorizedClient(any(String.class), any())).thenReturn(Mono.just(authorizedClient));
        
        OAuth2AuthenticationToken authenticationToken = new OAuth2AuthenticationToken(mock(OAuth2User.class),
                Collections.emptyList(), "myId");
        SecurityContextImpl securityContext = new SecurityContextImpl(authenticationToken);
        SecurityContextServerWebExchange exchange = new SecurityContextServerWebExchange(mockExchange, Mono.just(securityContext));
    
        oAuth2Plugin.doExecute(exchange, chain, null, null).block(TIMEOUT);
    
        assertTrue(request.getHeaders().containsKey(HttpHeaders.AUTHORIZATION));
        assertTrue(Objects.requireNonNull(request.getHeaders().get(HttpHeaders.AUTHORIZATION)).contains("Bearer token"));
    }