From c1c2e1e8437bc2572e966f99d33745018fbccf05 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 1 Dec 2023 22:59:39 +0900 Subject: [PATCH] =?UTF-8?q?test:=20OAuth2=E3=81=A7=E3=81=AE=E3=83=88?= =?UTF-8?q?=E3=83=BC=E3=82=AF=E3=83=B3=E4=BD=9C=E6=88=90=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/e2eTest/resources/application.yml | 4 ++++ src/e2eTest/resources/logback.xml | 8 +++++++ .../resources/oauth2/Oauth2LoginTest.feature | 24 ++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/e2eTest/resources/application.yml b/src/e2eTest/resources/application.yml index b40fcd91..69e0ebcd 100644 --- a/src/e2eTest/resources/application.yml +++ b/src/e2eTest/resources/application.yml @@ -40,3 +40,7 @@ spring: # excluded-packages: dev.usbharu.hideout.core.infrastructure.kjobexposed server: port: 8080 + tomcat: + basedir: tomcat-e2e + accesslog: + enabled: true diff --git a/src/e2eTest/resources/logback.xml b/src/e2eTest/resources/logback.xml index a8bb21c4..7f19e2eb 100644 --- a/src/e2eTest/resources/logback.xml +++ b/src/e2eTest/resources/logback.xml @@ -1,4 +1,11 @@ + + ./e2eTest.log + + UTF-8 + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{x-request-id}] %logger{36} - %msg%n + + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{x-request-id}] %logger{36} - %msg%n @@ -6,6 +13,7 @@ + diff --git a/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature b/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature index 29ae760c..582af835 100644 --- a/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature +++ b/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature @@ -10,7 +10,7 @@ Feature: OAuth2 Login Test """ { "client_name": "oauth2-test-client-1", - "redirect_uris": "https://example.com", + "redirect_uris": "https://usbharu.dev", "scopes": "write read" } """ @@ -23,10 +23,28 @@ Feature: OAuth2 Login Test * def client_id = response.client_id * def client_secret = response.client_secret - * def authorizeEndpoint = baseUrl + '/oauth/authorize?response_type=code&redirect_uri=https://example.com&client_id=' + client_id + '&scope=write read' + * def authorizeEndpoint = baseUrl + '/oauth/authorize?response_type=code&redirect_uri=https://usbharu.dev&client_id=' + client_id + '&scope=write%20read' Given driver authorizeEndpoint And driver.input('#username','test-user') And driver.input('#password','password') + When driver.submit().click('body > div > form > button') - Then match driver.title == 'test' + Then driver.waitForUrl(authorizeEndpoint + "&continue") + And driver.click('#read') + And driver.click('#write') + + When driver.submit().click('#submit-consent') + Then driver.waitUntil("location.host == 'usbharu.dev'") + + * def code = script("new URLSearchParams(document.location.search).get('code')") + + Given path '/oauth/token' + And form field client_id = client_id + And form field client_secret = client_secret + And form field redirect_uri = 'https://usbharu.dev' + And form field grant_type = 'authorization_code' + And form field code = code + And form field scope = 'write read' + When method post + Then status 200