|
| 1 | +/* |
| 2 | + * Wave, containers provisioning service |
| 3 | + * Copyright (c) 2023-2024, Seqera Labs |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +package io.seqera.wave.service.pairing |
| 20 | + |
| 21 | +import spock.lang.Specification |
| 22 | + |
| 23 | +import io.micronaut.context.ApplicationContext |
| 24 | +import io.micronaut.test.extensions.spock.annotation.MicronautTest |
| 25 | +import io.seqera.wave.service.pairing.socket.PairingWebSocket |
| 26 | + |
| 27 | +/** |
| 28 | + * |
| 29 | + * @author Paolo Di Tommaso <[email protected]> |
| 30 | + */ |
| 31 | +@MicronautTest |
| 32 | +class PairingWebSocketTest extends Specification { |
| 33 | + |
| 34 | + def 'should allow any host' () { |
| 35 | + given: |
| 36 | + def ctx = ApplicationContext.run() |
| 37 | + def pairing = ctx.getBean(PairingWebSocket) |
| 38 | + |
| 39 | + expect: |
| 40 | + !pairing.isDenyHost('foo') |
| 41 | + !pairing.isDenyHost('seqera.io') |
| 42 | + !pairing.isDenyHost('ngrok') |
| 43 | + |
| 44 | + cleanup: |
| 45 | + ctx.close() |
| 46 | + } |
| 47 | + |
| 48 | + def 'should disallowed deny hosts' () { |
| 49 | + given: |
| 50 | + def ctx = ApplicationContext.run(['wave.denyHosts': ['ngrok','hctal']]) |
| 51 | + def pairing = ctx.getBean(PairingWebSocket) |
| 52 | + |
| 53 | + expect: |
| 54 | + pairing.isDenyHost('ngrok') |
| 55 | + pairing.isDenyHost('hctal') |
| 56 | + and: |
| 57 | + !pairing.isDenyHost('seqera.io') |
| 58 | + |
| 59 | + cleanup: |
| 60 | + ctx.close() |
| 61 | + } |
| 62 | +} |
0 commit comments