Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ› restdocs dose not create documents #114

Closed
HaiSeong opened this issue Jul 27, 2024 · 1 comment
Closed

๐Ÿ› restdocs dose not create documents #114

HaiSeong opened this issue Jul 27, 2024 · 1 comment
Assignees
Labels

Comments

@HaiSeong
Copy link

HaiSeong commented Jul 27, 2024

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-07-27 แ„‹แ…ฉแ„’แ…ฎ 11 07 32

102๋ฒˆ pr์—์„œ ํ•˜๋ผ๊ณ ํ•œ ๋ชจ๋“  ์ž‘์—…์„ ํ•ด์ฃผ์—ˆ์ง€๋งŒ ๋ฌธ์„œ๊ฐ€ ๋งŒ๋“ค์–ด ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

@Sql("/data/users.sql")
class LoginControllerTest extends RestDocsSetting {

    @MockBean
    private FirebaseAuth firebaseAuth;
    @Autowired
    private JwtTokenManager jwtTokenManager;

    @Test
    @DisplayName("์ด๋ฏธ ๊ฐ€์ž…๋œ ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋ฉด ์ด๋ฏธ ๊ฐ€์ž…๋˜์—ˆ๋‹ค๊ณ  ์•Œ๋ฆฌ๊ณ  access token๊ณผ refresh token์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.")
    void loginWithGoogleWithEmailAlreadyRegistered() throws FirebaseAuthException {
        String email = "[email protected]";
        String idToken = "test.id.token";

        FirebaseToken firebaseToken = mock(FirebaseToken.class);
        when(firebaseToken.getEmail()).thenReturn(email);
        when(firebaseAuth.verifyIdToken(idToken)).thenReturn(firebaseToken);

        GoogleLoginResponse actual = RestAssured.given(spec).log().all()
                .filter(document(DEFAULT_RESTDOCS_PATH,
                        requestFields(
                                fieldWithPath("idToken").description("Google ID Token")
                        ),
                        responseFields(
                                fieldWithPath("accessToken").description("JWT Access Token"),
                                fieldWithPath("refreshToken").description("JWT Refresh Token"),
                                fieldWithPath("registered").description("์‚ฌ์šฉ์ž ๋“ฑ๋ก ์—ฌ๋ถ€")
                        )
                ))
                .contentType(ContentType.JSON)
                .body(new GoogleLoginRequest(idToken))
                .when().post("/api/oauth/google/login")
                .then().log().all()
                .statusCode(200)
                .extract()
                .as(GoogleLoginResponse.class);

        assertAll(
                () -> assertThat(actual.accessToken()).isNotNull(),
                () -> assertThat(actual.refreshToken()).isNotNull(),
                () -> assertThat(actual.registered()).isTrue()
        );
    }

...
@HaiSeong
Copy link
Author

์›์ธ ์ฐพ์•˜์Šต๋‹ˆ๋‹ค. document๋ฅผ static import ํ• ๋•Œ ์ฃผ์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document ๋ฐ›์œผ๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค.
com.epages.restdocs.apispec.RestAssuredRestDocumentationWrapper.document ์ž„ํฌํŠธ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

import static com.epages.restdocs.apispec.RestAssuredRestDocumentationWrapper.document;

๊ผญ ์ด๊ฑฐ import ํ•˜์„ธ์š”.

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-07-28 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12 55 50

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-07-28 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 12 56 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants