Skip to content

Commit

Permalink
Nwi4 bug during modify- hierarchy check (#1451)
Browse files Browse the repository at this point in the history
* fix nwi4 bug for modify ALLOCATED-ASSIGNED PA with a child ASSIGNED PA

* fix build

* add tests

* refactor

* add tests

* refactor

* remove unused imports

* javadocs

* use subclass for modify

* refactor

---------

Co-authored-by: Ed Shryane <[email protected]>
  • Loading branch information
maggarwal13 and eshryane authored Apr 30, 2024
1 parent 00effd2 commit bc5b01b
Show file tree
Hide file tree
Showing 7 changed files with 530 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,47 @@ class InetnumIntegrationSpec extends BaseWhoisSourceSpec {
object/
}


def "modify status ALLOCATED ASSIGNED PA status to ASSIGNED PA fails"() {
given:
def insertResponse = syncUpdate(new SyncUpdate(data: """\
inetnum: 192.0.0.0/24
netname: RIPE-NCC
descr: description
country: DK
admin-c: TEST-PN
tech-c: TEST-PN
status: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: hm
password: update
""".stripIndent(true)))
when:
insertResponse =~ /SUCCESS/
then:
def response = syncUpdate new SyncUpdate(data: """\
inetnum: 192.0.0.0/24
netname: RIPE-NCC
descr: description
country: DK
admin-c: TEST-PN
tech-c: TEST-PN
status: ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
""".stripIndent(true))
then:
response =~ /Modify FAILED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
response =~ /\*\*\*Error: status value cannot be changed, you must delete and re-create the
object/
}

def "handle failure of out-of-range CIDR notation"() {
when:
def response = syncUpdate(new SyncUpdate(data: """\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,50 @@ class InetnumStatusBetweenSpec extends BaseQueryUpdateSpec {
queryObjectNotFound("-rGBT inetnum 192.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")
}

def "create between ALLOCATED UNSPECIFIED and ALLOCATED UNSPECIFIED, with status ALLOCATED-ASSIGNED PA"() {
given:
syncUpdate(getTransient("ALLOC-UNS") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.0.0.0 - 192.255.255.255", "inetnum", "192.0.0.0 - 192.255.255.255")
syncUpdate(getTransient("ALLOC-UNS2") + "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.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")

when:
def ack = syncUpdateWithResponse("""\
inetnum: 192.100.0.0 - 192.200.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: LIR-MNT
source: TEST
password: hm
password: owner3
password: lir
""".stripIndent(true)
)

then:

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.100.0.0 - 192.200.255.255" }
ack.errorMessagesFor("Create", "[inetnum] 192.100.0.0 - 192.200.255.255") ==
["Status ALLOCATED-ASSIGNED PA not allowed when more specific object '192.168.0.0 - 192.169.255.255' has status ALLOCATED UNSPECIFIED"]

queryObjectNotFound("-rGBT inetnum 192.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")
}

def "create between ALLOCATED UNSPECIFIED and ALLOCATED UNSPECIFIED, with status LIR-PARTITIONED PA"() {
given:
syncUpdate(getTransient("ALLOC-UNS") + "password: owner3\npassword: hm")
Expand Down Expand Up @@ -649,6 +693,50 @@ class InetnumStatusBetweenSpec extends BaseQueryUpdateSpec {
queryObjectNotFound("-rGBT inetnum 192.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")
}

def "create between ALLOCATED UNSPECIFIED and ALLOCATED PA, with status ALLOCATED-ASSIGNED PA"() {
given:
syncUpdate(getTransient("ALLOC-UNS") + "password: owner3\npassword: hm")
queryObject("-r -T inetnum 192.0.0.0 - 192.255.255.255", "inetnum", "192.0.0.0 - 192.255.255.255")
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.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")

when:
def ack = syncUpdateWithResponse("""\
inetnum: 192.100.0.0 - 192.200.255.255
netname: TEST-NET-NAME
descr: TEST network
country: NL
org: ORG-LIR1-TEST
admin-c: TP1-TEST
tech-c: TP1-TEST
status: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: LIR-MNT
source: TEST
password: hm
password: owner3
password: lir
""".stripIndent(true)
)

then:

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.100.0.0 - 192.200.255.255" }
ack.errorMessagesFor("Create", "[inetnum] 192.100.0.0 - 192.200.255.255") ==
["Status ALLOCATED-ASSIGNED PA not allowed when more specific object '192.168.0.0 - 192.169.255.255' has status ALLOCATED PA"]

queryObjectNotFound("-rGBT inetnum 192.100.0.0 - 192.200.255.255", "inetnum", "192.100.0.0 - 192.200.255.255")
}

def "create between ALLOCATED UNSPECIFIED and ALLOCATED PA, with status LIR-PARTITIONED PA"() {
given:
syncUpdate(getTransient("ALLOC-UNS") + "password: owner3\npassword: hm")
Expand Down
Loading

0 comments on commit bc5b01b

Please sign in to comment.