Skip to content

Commit

Permalink
Inetnum AGGREGATED-BY-LIR status (#1467)
Browse files Browse the repository at this point in the history
* add new AGGREGATED-BY-LIR for inetnum

* fix build

* refactor

* add assignment size tests

* add modify assignment-size tests

* add success create child AGGREGATED-BY-LIR tests

* Add  tests for create child  parent AGGREGATED-BY-LIR

* add hierarchy level tests

* add in between tests

* fix tests

---------

Co-authored-by: Ed Shryane <eshryane@ripe.net>
  • Loading branch information
maggarwal13 and eshryane authored May 30, 2024
1 parent fdec494 commit bae075e
Show file tree
Hide file tree
Showing 13 changed files with 1,189 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,19 @@ class InetnumSpec extends BaseQueryUpdateSpec {
mnt-lower: LIR-MNT
source: TEST
""",
"AGGREGATED-LIR": """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
""",
"LEGACY-USER-ONLY": """\
inetnum: 192.168.0.0 - 192.168.255.255
netname: RIPE-NET1
Expand Down Expand Up @@ -3981,7 +3994,7 @@ class InetnumSpec extends BaseQueryUpdateSpec {
queryObjectNotFound("-rGBT inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")
}

def "create with IPv6 status"() {
def "create inetnum with status AGGREGATED-BY-LIR, assignment-size optional"() {
given:
syncUpdate(getTransient("ALLOC-PA") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.168.0.0 - 192.169.255.255", "inetnum", "192.168.0.0 - 192.169.255.255")
Expand Down Expand Up @@ -4011,18 +4024,212 @@ class InetnumSpec extends BaseQueryUpdateSpec {
)

then:
def ack = ackFor message

ack.summary.nrFound == 1
ack.summary.assertSuccess(1, 1, 0, 0, 0)
ack.summary.assertErrors(0, 0, 0, 0)

ack.successes.any { it.operation == "Create" && it.key == "[inetnum] 192.168.0.255 - 192.168.255.255" }

queryObject("-rGBT inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

}

def "create inetnum with status AGGREGATED-BY-LIR, with assignment-size"() {
given:
syncUpdate(getTransient("ALLOC-PA") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.168.0.0 - 192.169.255.255", "inetnum", "192.168.0.0 - 192.169.255.255")

expect:
queryObjectNotFound("-r -T inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

when:
def message = send new Message(
subject: "",
body: """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
assignment-size: 32
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
password: owner3
password: lir
""".stripIndent(true)
)

then:
def ack = ackFor message

ack.summary.nrFound == 1
ack.summary.assertSuccess(1, 1, 0, 0, 0)
ack.summary.assertErrors(0, 0, 0, 0)

ack.successes.any { it.operation == "Create" && it.key == "[inetnum] 192.168.0.255 - 192.168.255.255" }

queryObject("-rGBT inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

}

def "create inetnum with status AGGREGATED-BY-LIR, with incorrect assignment-size"() {
given:
syncUpdate(getTransient("ALLOC-PA") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.168.0.0 - 192.169.255.255", "inetnum", "192.168.0.0 - 192.169.255.255")

expect:
queryObjectNotFound("-r -T inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

when:
def message = send new Message(
subject: "",
body: """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
assignment-size: 40
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
password: owner3
password: lir
""".stripIndent(true)
)

then:
def ack = ackFor message


ack.summary.nrFound == 1
ack.summary.assertSuccess(0, 0, 0, 0, 0)
ack.summary.assertErrors(1, 1, 0, 0)

ack.countErrorWarnInfo(1, 0, 0)
ack.errors.any { it.operation == "Create" && it.key == "[inetnum] 192.168.0.255 - 192.168.255.255" }
ack.errorMessagesFor("Create", "[inetnum] 192.168.0.255 - 192.168.255.255") ==
["Syntax error in AGGREGATED-BY-LIR"]
["\"assignment-size:\" value must not be greater than the maximum prefix size 32"]

queryObjectNotFound("-rGBT inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

}

def "modify inetnum with status AGGREGATED-BY-LIR, add assignment-size fails"() {
given:
syncUpdate(getTransient("ALLOC-PA") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.168.0.0 - 192.169.255.255", "inetnum", "192.168.0.0 - 192.169.255.255")

syncUpdate(getTransient("AGGREGATED-LIR") + "password: owner3\npassword: lir")
queryObject("-r -T inetnum 192.168.0.255 - 192.168.255.255", "inetnum", "192.168.0.255 - 192.168.255.255")

when:
def message = send new Message(
subject: "",
body: """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
assignment-size: 32
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
password: owner3
password: lir
""".stripIndent(true)
)

then:
def ack = ackFor message

ack.summary.nrFound == 1
ack.summary.assertSuccess(0, 0, 0, 0, 0)
ack.summary.assertErrors(1, 0, 1, 0)

ack.countErrorWarnInfo(1, 0, 0)
ack.errors.any { it.operation == "Modify" && it.key == "[inetnum] 192.168.0.255 - 192.168.255.255" }
ack.errorMessagesFor("Modify", "[inetnum] 192.168.0.255 - 192.168.255.255") ==
["\"assignment-size:\" value cannot be changed"]

}

def "modify inetnum with status AGGREGATED-BY-LIR, can not change assignment-size"() {
given:
syncUpdate(getTransient("ALLOC-PA") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.168.0.0 - 192.169.255.255", "inetnum", "192.168.0.0 - 192.169.255.255")


def child = syncUpdate(new SyncUpdate(data: """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
assignment-size: 32
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
password: owner3
password: lir
""".stripIndent(true)))

expect:
child =~ /SUCCESS/

when:
def message = send new Message(
subject: "",
body: """\
inetnum: 192.168.0.255 - 192.168.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: AGGREGATED-BY-LIR
assignment-size: 28
mnt-by: lir-MNT
mnt-lower: LIR-MNT
source: TEST
password: owner3
password: lir
""".stripIndent(true)
)

then:
def ack = ackFor message

ack.summary.nrFound == 1
ack.summary.assertSuccess(0, 0, 0, 0, 0)
ack.summary.assertErrors(1, 0, 1, 0)

ack.countErrorWarnInfo(1, 0, 0)
ack.errors.any { it.operation == "Modify" && it.key == "[inetnum] 192.168.0.255 - 192.168.255.255" }
ack.errorMessagesFor("Modify", "[inetnum] 192.168.0.255 - 192.168.255.255") ==
["\"assignment-size:\" value cannot be changed"]
}

def "create ASSIGNED PA, invalid range, reversed"() {
Expand Down
Loading

0 comments on commit bae075e

Please sign in to comment.