Fix/unions (#2825)

* mocks for union value

* fix: properly handle values in unions

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Alex Inkin
2025-02-06 21:06:04 +04:00
committed by GitHub
parent 04611b0ae2
commit 4e22f13007
3 changed files with 53 additions and 19 deletions

View File

@@ -1519,7 +1519,43 @@ export module Mock {
},
internal: {
name: 'Internal',
spec: ISB.InputSpec.of({}),
spec: ISB.InputSpec.of({
listitems: ISB.Value.list(
ISB.List.text(
{
name: 'RPC Allowed IPs',
minLength: 1,
maxLength: 10,
default: ['192.168.1.1'],
description:
'external ip addresses that are authorized to access your Bitcoin node',
warning:
'Any IP you allow here will have RPC access to your Bitcoin node.',
},
{
patterns: [
{
regex:
'((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|((^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)|(^[a-z2-7]{16}\\.onion$)|(^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$))',
description:
'must be a valid ipv4, ipv6, or domain name',
},
],
},
),
),
name: ISB.Value.text({
name: 'Name',
required: false,
default: null,
patterns: [
{
regex: '^[a-zA-Z]+$',
description: 'Must contain only letters.',
},
],
}),
}),
},
external: {
name: 'External',
@@ -1667,6 +1703,10 @@ export module Mock {
},
'bitcoin-node': {
selection: 'internal',
value: {
listitems: ['192.168.1.1', '192.1681.23'],
name: 'Matt',
},
},
port: 20,
rpcallowip: undefined,