All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ngeor.yak4j.ResultActionsHelper Maven / Gradle / Ivy

package com.github.ngeor.yak4j;

import org.springframework.test.web.servlet.ResultActions;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;

/**
 * Utility class to help with asserting CORS headers on {@link ResultActions}.
 */
@SuppressWarnings({"unused", "WeakerAccess"})
public final class ResultActionsHelper {

    private ResultActionsHelper() {
    }

    /**
     * Verifies that the expected CORS headers exist on the given response.
     * @param resultActions The result actions that
     * @throws Exception When an expectation is not met.
     */
    public static void assertCorsHeaders(ResultActions resultActions) throws Exception {
        resultActions.andExpect(
            header().string("Access-Control-Allow-Origin", "*")
        ).andExpect(
            header().string("Access-Control-Allow-Headers", "Authorization, Content-Type")
        ).andExpect(
            header().string("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy