@@ -31,45 +31,28 @@ struct RequestSchemeTests {
3131 @Test ( arguments: [
3232 TestArg ( scheme: " http " , host: " myregistry.io " , expected: . http) ,
3333 TestArg ( scheme: " https " , host: " myregistry.io " , expected: . https) ,
34- TestArg ( scheme: " auto " , host: " myregistry.io " , expected: . https) ,
3534 TestArg ( scheme: " https " , host: " localhost " , expected: . https) ,
3635 TestArg ( scheme: " http " , host: " localhost " , expected: . http) ,
37- TestArg ( scheme: " auto " , host: " localhost " , expected: . http) ,
38- TestArg ( scheme: " auto " , host: " localhost.evil.com " , expected: . https) ,
3936 TestArg ( scheme: " http " , host: " 127.0.0.1 " , expected: . http) ,
4037 TestArg ( scheme: " https " , host: " 127.0.0.1 " , expected: . https) ,
41- TestArg ( scheme: " auto " , host: " 127.0.0.1 " , expected: . http) ,
42- TestArg ( scheme: " auto " , host: " 127.255.255.255 " , expected: . http) ,
43- TestArg ( scheme: " auto " , host: " 127.0.0.1.evil.com " , expected: . https) ,
4438 TestArg ( scheme: " https " , host: " 10.3.4.1 " , expected: . https) ,
45- TestArg ( scheme: " auto " , host: " 10.3.4.1 " , expected: . http) ,
46- TestArg ( scheme: " auto " , host: " 10.255.255.255 " , expected: . http) ,
47- TestArg ( scheme: " auto " , host: " 10.0.0.1.evil.com " , expected: . https) ,
48- TestArg ( scheme: " auto " , host: " 192.168.0.1 " , expected: . http) ,
49- TestArg ( scheme: " auto " , host: " 192.168.255.255 " , expected: . http) ,
50- TestArg ( scheme: " auto " , host: " 192.169.0.1 " , expected: . https) ,
51- TestArg ( scheme: " auto " , host: " 192.168.1.1.evil.com " , expected: . https) ,
52- TestArg ( scheme: " auto " , host: " some-dns-name.io " , expected: . https) ,
53- TestArg ( scheme: " auto " , host: " 172.32.0.1 " , expected: . https) ,
54- TestArg ( scheme: " auto " , host: " 172.22.23.61 " , expected: . http) ,
55- TestArg ( scheme: " auto " , host: " 172.16.0.0 " , expected: . http) ,
56- TestArg ( scheme: " auto " , host: " 172.31.255.255 " , expected: . http) ,
5739 ] )
5840
5941 func testIsConnectionSecure( arg: TestArg ) throws {
60- let requestScheme = RequestScheme ( rawValue : arg. scheme) !
42+ let requestScheme = try RequestScheme ( arg. scheme)
6143 #expect( try requestScheme. schemeFor ( host: arg. host, internalDnsDomain: Self . defaultDnsDomain) == arg. expected)
6244 }
6345
6446 @Test func testEmptyHostThrowsError( ) throws {
6547 #expect( throws: ( any Error ) . self) {
66- let requestScheme = RequestScheme ( rawValue : " https " ) !
48+ let requestScheme = try RequestScheme ( " https " )
6749 _ = try requestScheme. schemeFor ( host: " " , internalDnsDomain: Self . defaultDnsDomain)
6850 }
6951 }
7052
71- @Test func testIsInternalHostWithDefaultDNSDomain( ) throws {
72- let hostName = " some-dns-name.io. \( Self . defaultDnsDomain) "
73- #expect( RequestScheme . isInternalHost ( host: hostName, internalDnsDomain: Self . defaultDnsDomain) )
53+ @Test func testUnsupportedSchemeThrowsError( ) throws {
54+ #expect( throws: ( any Error ) . self) {
55+ _ = try RequestScheme ( " auto " )
56+ }
7457 }
7558}
0 commit comments