Login unit test
This commit is contained in:
parent
ca9fcaf2f9
commit
60c6f318d6
@ -1,13 +1,32 @@
|
|||||||
package com.indexzero.finals;
|
package com.indexzero.finals;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
|
@AutoConfigureMockMvc
|
||||||
class NtoFinalsApplicationTests {
|
class NtoFinalsApplicationTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void userLogin() throws Exception {
|
||||||
|
this.mockMvc.perform(
|
||||||
|
post("/api/employee/login")
|
||||||
|
.with(httpBasic("pivanov", "HelloWorld1234"))
|
||||||
|
)
|
||||||
|
.andDo(print())
|
||||||
|
.andExpect(status().isOk()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user