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

[TECHNICAL] Pending unit tests for OCRemoteServerInfoDataSource #4520

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Abel García de Prada
* @author Juan Carlos Garrote Gascón
*
* Copyright (C) 2023 ownCloud GmbH.
* Copyright (C) 2024 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -213,7 +213,7 @@ class OCRemoteServerInfoDataSourceTest {
fun `getServerInfo returns ServerInfo with bearer and insecure connection`() {
val expectedValue = OC_INSECURE_SERVER_INFO_BEARER_AUTH

prepareRemoteStatusToBeRetrieved(remoteServerInfo.copy(baseUrl = expectedValue.baseUrl, isSecureConnection = true))
prepareRemoteStatusToBeRetrieved(remoteServerInfo.copy(baseUrl = expectedValue.baseUrl, isSecureConnection = false))
prepareAuthorizationMethodToBeRetrieved(AuthenticationMethod.BEARER_TOKEN, true)

val currentValue = ocRemoteServerInfoDatasource.getServerInfo(expectedValue.baseUrl, false)
Expand All @@ -223,6 +223,18 @@ class OCRemoteServerInfoDataSourceTest {
verify(exactly = 1) { ocServerInfoService.checkPathExistence(expectedValue.baseUrl, false, ocClientMocked) }
}

@Test
fun `getServerInfo returns ServerInfo with bearer and secure connection when OIDC enforcement is enabled`() {
val expectedValue = OC_SECURE_SERVER_INFO_BEARER_AUTH

prepareRemoteStatusToBeRetrieved(remoteServerInfo.copy(baseUrl = expectedValue.baseUrl, isSecureConnection = true))

val currentValue = ocRemoteServerInfoDatasource.getServerInfo(expectedValue.baseUrl, true)
assertEquals(expectedValue, currentValue)

verify(exactly = 1) { ocServerInfoService.getRemoteStatus(expectedValue.baseUrl, ocClientMocked) }
}

@Test(expected = NoConnectionWithServerException::class)
fun `getServerInfo throws exception when there is no connection with the server`() {
prepareRemoteStatusToBeRetrieved(remoteServerInfo, NoConnectionWithServerException())
Expand Down
Loading