@Test
    void verifyFeed() throws Throwable {
        var mv = mockMvc.perform(get(SamlIdentityProviderDiscoveryFeedController.BASE_ENDPOINT_IDP_DISCOVERY)
                .contentType(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
            )
            .andExpect(status().isOk())
            .andReturn()
            .getModelAndView();
        assertNotNull(mv.getModel());
        assertFalse(mv.getModel().isEmpty());

        mv = mockMvc.perform(get(SamlIdentityProviderDiscoveryFeedController.BASE_ENDPOINT_IDP_DISCOVERY)
                .contentType(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
            )
            .andExpect(status().isOk())
            .andReturn()
            .getModelAndView();
        assertNotNull(mv.getModel());
        assertFalse(mv.getModel().isEmpty());

        mockMvc.perform(get(SamlIdentityProviderDiscoveryFeedController.BASE_ENDPOINT_IDP_DISCOVERY + "/feed")
                .contentType(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
                .queryParam("entityID", "https://cas.example.org/idp")
            )
            .andExpect(status().isOk())
            .andExpect(jsonPath("$", Matchers.hasSize(1)));
        assertNotNull(mv.getModel());
        assertFalse(mv.getModel().isEmpty());

        mv = mockMvc.perform(get(SamlIdentityProviderDiscoveryFeedController.BASE_ENDPOINT_IDP_DISCOVERY + "/redirect")
                .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
                .accept(MediaType.APPLICATION_JSON)
                .queryParam("entityID", "https://cas.example.org/idp")
            )
            .andExpect(status().isMovedTemporarily())
            .andReturn()
            .getModelAndView();
        assertNotNull(mv.getView());

        val accessStrategy = new DefaultRegisteredServiceAccessStrategy();
        val policy = new DefaultRegisteredServiceDelegatedAuthenticationPolicy();
        policy.setAllowedProviders(List.of("OtherClient"));
        policy.setPermitUndefined(false);
        accessStrategy.setDelegatedAuthenticationPolicy(policy);
        val service = RegisteredServiceTestUtils.getRegisteredService("https://service.example");
        service.setAccessStrategy(accessStrategy);
        servicesManager.save(service);

        mockMvc.perform(get(SamlIdentityProviderDiscoveryFeedController.BASE_ENDPOINT_IDP_DISCOVERY + "/redirect")
                .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
                .accept(MediaType.APPLICATION_JSON)
                .queryParam(CasProtocolConstants.PARAMETER_SERVICE, "https://service.example")
                .queryParam("entityID", "https://cas.example.org/idp")
            )
            .andExpect(status().isForbidden());
    }
This is {@link SamlIdentityProviderDiscoveryFeedControllerTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-saml-idp-discovery/src/test/java/org/apereo/cas/web/SamlIdentityProviderDiscoveryFeedControllerTests.java