Skip to content

Commit

Permalink
feat:蓝盾APP Oauth2授权登录实现 #9353
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Nov 17, 2023
1 parent d2f406f commit 791c192
Showing 1 changed file with 13 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ class Oauth2ClientServiceTest : BkCiAbstractTest() {
dslContext = dslContext,
authOauth2ClientDetailsDao = authOauth2ClientDetailsDao
)
private val clientId = "testClient"

private val clientDetails = ClientDetailsInfo(
clientId = "testClient",
clientSecret = "testSecret",
clientName = "Test Client",
scope = "read,write",
authorizedGrantTypes = "authorization_code,refresh_token",
redirectUri = "http://example.com/callback,http://example1.com/callback",
accessTokenValidity = 3600,
refreshTokenValidity = 86400,
icon = "icon"
)

@Test
fun `test verifyClientInformation with invalid grant type`() {
val clientId = "testClient"
val clientDetails = ClientDetailsInfo(
clientId = clientId,
clientSecret = "testSecret",
clientName = "Test Client",
scope = "read,write",
authorizedGrantTypes = "authorization_code,refresh_token",
redirectUri = "http://example.com/callback",
accessTokenValidity = 3600,
refreshTokenValidity = 86400,
icon = "icon"
)

val invalidGrantType = "invalid_grant_type"

val exception = assertThrows<ErrorCodeException> {
Expand All @@ -50,19 +50,6 @@ class Oauth2ClientServiceTest : BkCiAbstractTest() {

@Test
fun `test verifyClientInformation with invalid redirect URI`() {
val clientId = "testClient"
val clientDetails = ClientDetailsInfo(
clientId = clientId,
clientSecret = "testSecret",
clientName = "Test Client",
scope = "read,write",
authorizedGrantTypes = "authorization_code",
redirectUri = "http://example.com/callback",
accessTokenValidity = 3600,
refreshTokenValidity = 86400,
icon = "icon"
)

val invalidRedirectUri = "http://invalid.com/callback"

val exception = assertThrows<ErrorCodeException> {
Expand All @@ -79,19 +66,6 @@ class Oauth2ClientServiceTest : BkCiAbstractTest() {

@Test
fun `test verifyClientInformation with invalid client secret`() {
val clientId = "testClient"
val clientDetails = ClientDetailsInfo(
clientId = clientId,
clientSecret = "testSecret",
clientName = "Test Client",
scope = "read,write",
authorizedGrantTypes = "authorization_code",
redirectUri = "http://example.com/callback",
accessTokenValidity = 3600,
refreshTokenValidity = 86400,
icon = "icon"
)

val invalidClientSecret = "invalidSecret"

val exception = assertThrows<ErrorCodeException> {
Expand All @@ -108,19 +82,6 @@ class Oauth2ClientServiceTest : BkCiAbstractTest() {

@Test
fun `test verifyClientInformation with invalid scope`() {
val clientId = "testClient"
val clientDetails = ClientDetailsInfo(
clientId = clientId,
clientSecret = "testSecret",
clientName = "Test Client",
scope = "read,write",
authorizedGrantTypes = "authorization_code",
redirectUri = "http://example.com/callback",
accessTokenValidity = 3600,
refreshTokenValidity = 86400,
icon = "icon"
)

val invalidScope = listOf("invalidScope")

val exception = assertThrows<ErrorCodeException> {
Expand Down

0 comments on commit 791c192

Please sign in to comment.