Class AuthControllerIntegrationTest

java.lang.Object
me.josephsf.jobportaljosephsfeirtest.controller.AuthControllerIntegrationTest

@SpringBootTest(classes=JobPortalJosephSfeirApplication.class) @AutoConfigureMockMvc @TestPropertySource(properties="spring.data.mongodb.uri=mongodb+srv://JosephSfeir:Sfeir7705@job-portal-cluster.uihqk1x.mongodb.net/test_db?retryWrites=true&w=majority") public class AuthControllerIntegrationTest extends Object
  • Constructor Details

    • AuthControllerIntegrationTest

      public AuthControllerIntegrationTest()
  • Method Details

    • setup

      @BeforeEach public void setup()
      Set up test environment before each test.

      This method ensures that the test user doesn't exist in the database before running each test to avoid conflicts with previous test runs.

    • cleanup

      @AfterEach public void cleanup()
      Clean up test environment after each test.

      This method removes any test users created during test execution to leave the database in a clean state for subsequent tests.

    • testRegisterUser

      @Test public void testRegisterUser() throws Exception
      Tests user registration functionality.

      This test verifies that:

      • Users can successfully register with valid credentials
      • The system returns a success response
      • The user record is properly persisted in the database
      Throws:
      Exception - if an error occurs during the test
    • testLoginUser

      @Test public void testLoginUser() throws Exception
      Tests user login functionality.

      This test verifies that:

      • Users can log in with valid credentials
      • The system returns a JWT token upon successful authentication
      • User details are correctly included in the response
      Throws:
      Exception - if an error occurs during the test
    • testRegisterDuplicateUsername

      @Test public void testRegisterDuplicateUsername() throws Exception
      Tests handling of duplicate username during registration.

      This test verifies that:

      • The system prevents users from registering with an already taken username
      • The system returns an appropriate error response
      Throws:
      Exception - if an error occurs during the test