@@ -0,0 +1,2107 @@
+/*%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS%0A * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR%0A * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER%0A * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN%0A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%0A */%0A%0Apackage com.mpalourdio.hello.controllers;%0A%0Aimport com.mpalourdio.hello.AbstractTestRunner;%0Aimport org.apache.commons.codec.binary.Base64;%0Aimport org.junit.Test;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Value;%0Aimport org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;%0Aimport org.springframework.test.web.servlet.MockMvc;%0A%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0A%0A@WebMvcTest(BasicAuthController.class)%0Apublic class BasicAuthControllerTest extends AbstractTestRunner %7B%0A%0A    @Autowired%0A    private MockMvc mvc;%0A%0A    @Value(%22$%7Badmin.username%7D%22)%0A    private String login;%0A    @Value(%22$%7Badmin.password%7D%22)%0A    private String password;%0A%0A    @Test%0A    public void testBasicAuthWhenCredentialsAreOk() throws Exception %7B%0A        final String basicDigestHeaderValue =%0A                %22Basic %22 + new String(Base64.encodeBase64((login + %22:%22 + password).getBytes()));%0A        mvc.perform(get(%22/basicauth%22)%0A                .header(%22Authorization%22, basicDigestHeaderValue))%0A                .andExpect(status().isOk());%0A    %7D%0A%0A    @Test%0A    public void testWrongCredentialsReturnUnauthorized() throws Exception %7B%0A        final String basicDigestHeaderValue =%0A                %22Basic %22 + new String(Base64.encodeBase64((%22fuck:you%22).getBytes()));%0A%0A        mvc.perform(get(%22/basicauth%22)%0A                .header(%22Authorization%22, basicDigestHeaderValue))%0A                .andExpect(status().isUnauthorized());%0A    %7D%0A%7D%0A

Add tests for BasicAuthController