From 5ff06b88f713d5bae6a8beb7ae51140e595d0af6 Mon Sep 17 00:00:00 2001
From: usbharu <64310155+usbharu@users.noreply.github.com>
Date: Fri, 1 Dec 2023 23:53:22 +0900
Subject: [PATCH] =?UTF-8?q?test:=20=E5=88=A5=E3=81=AE=E3=82=B9=E3=82=B3?=
=?UTF-8?q?=E3=83=BC=E3=83=97=E3=82=92=E8=A6=81=E6=B1=82=E3=81=99=E3=82=8B?=
=?UTF-8?q?=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E3=81=AE=E3=83=86=E3=82=B9?=
=?UTF-8?q?=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/kotlin/oauth2/OAuth2LoginTest.kt | 11 +++++
src/e2eTest/resources/logback.xml | 2 +-
.../resources/oauth2/Oauth2LoginTest.feature | 45 +++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/src/e2eTest/kotlin/oauth2/OAuth2LoginTest.kt b/src/e2eTest/kotlin/oauth2/OAuth2LoginTest.kt
index ba524c0d..3dfece24 100644
--- a/src/e2eTest/kotlin/oauth2/OAuth2LoginTest.kt
+++ b/src/e2eTest/kotlin/oauth2/OAuth2LoginTest.kt
@@ -38,6 +38,17 @@ class OAuth2LoginTest {
)
}
+ @Karate.Test
+ @TestFactory
+ fun `スコープread_statuses write_statusesを持ったトークンの作成`(): Karate {
+ return KarateUtil.springBootKarateTest(
+ "Oauth2LoginTest",
+ "スコープread:statuses write:statusesを持ったトークンの作成",
+ javaClass,
+ port
+ )
+ }
+
companion object {
@JvmStatic
@AfterAll
diff --git a/src/e2eTest/resources/logback.xml b/src/e2eTest/resources/logback.xml
index 1eacbcd5..c21752ee 100644
--- a/src/e2eTest/resources/logback.xml
+++ b/src/e2eTest/resources/logback.xml
@@ -16,6 +16,6 @@
-
+
diff --git a/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature b/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature
index 582af835..f330c369 100644
--- a/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature
+++ b/src/e2eTest/resources/oauth2/Oauth2LoginTest.feature
@@ -48,3 +48,48 @@ Feature: OAuth2 Login Test
And form field scope = 'write read'
When method post
Then status 200
+
+ Scenario: スコープread:statuses write:statusesを持ったトークンの作成
+
+ * def apps =
+ """
+ {
+ "client_name": "oauth2-test-client-2",
+ "redirect_uris": "https://usbharu.dev",
+ "scopes": "read:statuses write:statuses"
+ }
+ """
+
+ Given path '/api/v1/apps'
+ And request apps
+ When method post
+ Then status 200
+
+ * def client_id = response.client_id
+ * def client_secret = response.client_secret
+
+ * def authorizeEndpoint = baseUrl + '/oauth/authorize?response_type=code&redirect_uri=https://usbharu.dev&client_id=' + client_id + '&scope=read:statuses+write:statuses'
+
+ Given driver authorizeEndpoint
+ And driver.input('#username','test-user')
+ And driver.input('#password','password')
+
+ When driver.submit().click('body > div > form > button')
+ Then driver.waitForUrl(authorizeEndpoint + "&continue")
+ And driver.click('/html/body/div/div[4]/div/form/div[1]/input')
+ And driver.click('/html/body/div/div[4]/div/form/div[2]/input')
+
+ 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