BAEL-802: Drools using rules from Excel Files (#2115)
* Add NDC and JBoss Logging to the demo application * NDC for Log4j, Log4j2 and JBoss Logging * Simplify NDC example by making it a single operation instead of two * Make NDC example as RestController, Use JBoss Logging only as a logging bridge * Fix merge conflicts in pull request - log-mdc pom.xml updated * BAEL-445 Update to Spring security SpEL example * BAEL-445: Change tabs to spaces in the updated code * BAEL-245: Add Enum Serialization exmaple * BAEL-245: Remove the folder jackson/src/test/java/com/baeldung/jackson/dtos/withEnum as the example is not used anymore * Add more enum serialization examples to align with previous example and prevent build fail * BAEL-611: Minor formatting changes * BAEL-611: Update Test case method names * BAEL-611 Add JAX-WS client and JUnit Test * BAEL-245: Issue 1753. Fix the typo - change from writeNumber() to writeString() * BAEL-741: Spring Security Multiple Authentication Providers * BAEL-741: Spring Security Multiple Authentication Providers * Remove unnecessary change in pom.xml * BAEL-802: Drools Excel example
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package org.baeldung.web;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.baeldung.multipleauthproviders.MultipleAuthProvidersApplication;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = MultipleAuthProvidersApplication.class)
|
||||
public class MultipleAuthProvidersApplicationTests {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void givenMemUsers_whenGetPingWithValidUser_thenOk() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("memuser", "pass");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(200);
|
||||
assertThat(result.getBody()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenExternalUsers_whenGetPingWithValidUser_thenOK() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("externaluser", "pass");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(200);
|
||||
assertThat(result.getBody()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAuthProviders_whenGetPingWithNoCred_then401() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing();
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(401);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAuthProviders_whenGetPingWithBadCred_then401() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("user", "bad_password");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(401);
|
||||
}
|
||||
|
||||
private ResponseEntity<String> makeRestCallToGetPing(String username, String password) {
|
||||
return restTemplate.withBasicAuth(username, password)
|
||||
.getForEntity("/api/ping", String.class, Collections.emptyMap());
|
||||
}
|
||||
|
||||
private ResponseEntity<String> makeRestCallToGetPing() {
|
||||
return restTemplate.getForEntity("/api/ping", String.class, Collections.emptyMap());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user