TlsTest.kt (1719B)
1 /* 2 * This file is part of LibEuFin. 3 * Copyright (C) 2024 Taler Systems S.A. 4 5 * LibEuFin is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation; either version 3, or 8 * (at your option) any later version. 9 10 * LibEuFin is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General 13 * Public License for more details. 14 15 * You should have received a copy of the GNU Affero General Public 16 * License along with LibEuFin; see the file COPYING. If not, see 17 * <http://www.gnu.org/licenses/> 18 */ 19 20 import io.ktor.client.* 21 import io.ktor.client.request.* 22 import io.ktor.client.plugins.* 23 import io.ktor.http.* 24 import org.junit.Test 25 import kotlin.io.path.Path 26 import kotlin.io.path.writeBytes 27 import kotlin.test.assertEquals 28 import kotlin.test.assertFails 29 import java.security.Security 30 import kotlinx.coroutines.runBlocking 31 import tech.libeufin.common.setupSecurityProperties 32 33 class TlsTest { 34 @Test 35 fun securityCheck() = runBlocking { 36 setupSecurityProperties() 37 38 val secureClient = HttpClient() 39 val checks = sequenceOf( 40 "expired", 41 "wrong.host", 42 "self-signed", 43 "untrusted-root", 44 "revoked", 45 // "no-sct", TODO when java support this 46 "preact-cli" 47 ) 48 for (check in checks) { 49 println("https://$check.badssl.com") 50 assertFails { 51 secureClient.get("https://$check.badssl.com") 52 } 53 } 54 } 55 }