Integration Tests

Overview

Comprehensive integration tests for all security scenarios.

Base Test Class

@SpringBootTest
@AutoConfigureMockMvc
@WithMockUser
public abstract class OrgSecurityIntTest {

    @Autowired
    protected MockMvc restMockMvc;

    @Autowired
    protected EntityManager em;

    protected Organization org1, org2, org3;
    protected OrgUser regularUser, adminUser;

    @BeforeEach
    public void setupOrgSecurity() {
        // Create test data
    }
}

Test Examples

@Test
@Transactional
public void regularUser_canReadOrg1Events() {
    List<Event> events = asUser("user", () ->
        eventQueryService.findByCriteria(new EventCriteria())
    );
    assertThat(events).hasSize(2);  // org1 and org2 only
}

See security-scenarios.adoc for complete test scenarios.