Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NWI-4: Add ALLOCATED-ASSIGNED PA inetnum status #1432

Merged
merged 20 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class GeolocationService {
InetnumStatus.ASSIGNED_PI,
InetnumStatus.ASSIGNED_ANYCAST,
InetnumStatus.ALLOCATED_PA,
InetnumStatus.ALLOCATED_ASSIGNED_PA,
InetnumStatus.ALLOCATED_UNSPECIFIED);

private static final Set<Inet6numStatus> STOP_AT_STATUS_IPV6 = Sets.immutableEnumSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,41 @@ public void parent_inetnum_with_geolocation_and_language() throws Exception {
assertThat(response, containsString("<link xlink:type=\"locator\" xlink:href=\"http://rest.db.ripe.net/lookup/test/inetnum/10.0.0.0 - 10.255.255.255\"/>"));
}

@Test
public void parent_inetnum_with_geolocation_allocated_Assigned_pa() throws Exception {
databaseHelper.addObject(
"inetnum: 10.0.0.0 - 10.255.255.255\n" +
"netname: RIPE-NCC\n" +
"language: EN\n" +
"geoloc: 52.375599 5.9888802\n" +
"descr: Private Network\n" +
"country: NL\n" +
"tech-c: TP1-TEST\n" +
"status: ALLOCATED UNSPECIFIED\n" +
"mnt-by: OWNER-MNT\n" +
"mnt-lower: OWNER-MNT\n" +
"source: TEST");
databaseHelper.addObject(
"inetnum: 10.1.0.0 - 10.1.255.255\n" +
"netname: RIPE-NCC\n" +
"descr: Private Network\n" +
"geoloc: 52.375599 4.899902\n" +
"country: NL\n" +
"tech-c: TP1-TEST\n" +
"status: ALLOCATED-ASSIGNED PA\n" +
"mnt-by: OWNER-MNT\n" +
"mnt-lower: OWNER-MNT\n" +
"source: TEST");
ipTreeUpdater.rebuild();

final String response = RestTest.target(getPort(), "whois/geolocation?ipkey=10.1.0.0%20-%2010.1.255.255")
.request(MediaType.APPLICATION_XML)
.get(String.class);

assertThat(response, containsString("<location value=\"52.375599 4.899902\">"));
assertThat(response, containsString("<link xlink:type=\"locator\" xlink:href=\"http://rest.db.ripe.net/lookup/test/inetnum/10.1.0.0 - 10.1.255.255\"/>"));
}

@Test
public void inet6num_with_geolocation_and_language() throws Exception {
databaseHelper.addObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ManagedAttributeSearch {
private static final ImmutableSet<AttributeType> AUT_NUM_ATTRIBUTES = Sets.immutableEnumSet(AttributeType.AUT_NUM, AttributeType.ORG, AttributeType.SPONSORING_ORG, AttributeType.STATUS, AttributeType.SOURCE);

private static final ImmutableSet<InetnumStatus> INETNUM_ASSIGNMENT_STATUSES = Sets.immutableEnumSet(InetnumStatus.ASSIGNED_PI, InetnumStatus.ASSIGNED_ANYCAST);
private static final ImmutableSet<InetnumStatus> INETNUM_ALLOCATION_STATUSES = Sets.immutableEnumSet(InetnumStatus.ALLOCATED_PA, InetnumStatus.ALLOCATED_UNSPECIFIED);
private static final ImmutableSet<InetnumStatus> INETNUM_ALLOCATION_STATUSES = Sets.immutableEnumSet(InetnumStatus.ALLOCATED_PA, InetnumStatus.ALLOCATED_ASSIGNED_PA, InetnumStatus.ALLOCATED_UNSPECIFIED);
private static final ImmutableSet<InetnumStatus> INETNUM_LEGACY_STATUSES = Sets.immutableEnumSet(InetnumStatus.LEGACY);
private static final ImmutableSet<Inet6numStatus> INET6NUM_ALLOCATION_STATUSES = Sets.immutableEnumSet(Inet6numStatus.ALLOCATED_BY_RIR);
private static final ImmutableSet<Inet6numStatus> INET6NUM_ASSIGNMENT_STATUSES = Sets.immutableEnumSet(Inet6numStatus.ASSIGNED_PI, Inet6numStatus.ASSIGNED_ANYCAST);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.ripe.db.whois.spec.integration


import net.ripe.db.whois.spec.domain.SyncUpdate
import org.junit.jupiter.api.Tag

Expand Down Expand Up @@ -373,6 +372,251 @@ class InetnumIntegrationSpec extends BaseWhoisSourceSpec {
response =~ /\*\*\*Info: Value 192.0.0.0\/24 converted to 192.0.0.0 - 192.0.0.255/
}

def "create ALLOCATED ASSIGNED PA inetnum using RS credentials"() {
when:
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: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
password: hm
""".stripIndent(true)))
then:
response =~ /Create SUCCEEDED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
response =~ /\*\*\*Info: Value 192.0.0.0\/24 converted to 192.0.0.0 - 192.0.0.255/
}

def "create ALLOCATED ASSIGNED PA inetnum using override credentials"() {
when:
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: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
override:denis,override1
""".stripIndent(true)))
then:
response =~ /Create SUCCEEDED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
response =~ /\*\*\*Info: Value 192.0.0.0\/24 converted to 192.0.0.0 - 192.0.0.255/
}

def "create ALLOCATED ASSIGNED PA inetnum failed without RS maintainer"() {
when:
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: ALLOCATED-ASSIGNED PA
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
password: hm
""".stripIndent(true)))
then:
response =~ /Create FAILED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
response.contains("***Error: Status ALLOCATED-ASSIGNED PA can only be created by the database\n" +
" administrator")
}

def "create ALLOCATED ASSIGNED PA inetnum failed using user credentials"() {
when:
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: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
""".stripIndent(true)))
then:
response =~ /Create FAILED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
response.contains("***Error: Setting status ALLOCATED-ASSIGNED PA requires administrative\n" +
" authorisation")
}

def "modify status ALLOCATED ASSIGNED PA status to ALLOCATED PA by using user credentials"() {
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: ALLOCATED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
""".stripIndent(true))
then:
response =~ /SUCCESS/
response =~ /Modify SUCCEEDED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
}

def "modify status ALLOCATED PA to ALLOCATED-ASSIGNED PA status by using user credentials"() {
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 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: ALLOCATED-ASSIGNED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-by: TEST-MNT
org: ORG-TOL5-TEST
source: TEST
password: update
""".stripIndent(true))
then:
response =~ /SUCCESS/
response =~ /Modify SUCCEEDED: \[inetnum\] 192.0.0.0 - 192.0.0.255/
}

def "modify status ALLOCATED PA to ALLOCATED UNSPECIFIED status 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 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: ALLOCATED UNSPECIFIED
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 "modify status ALLOCATED ASSIGNED PA status to ALLOCATED UNSPECIFIED 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: ALLOCATED UNSPECIFIED
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 Expand Up @@ -432,7 +676,7 @@ class InetnumIntegrationSpec extends BaseWhoisSourceSpec {
}

def "create status ALLOCATED PA no alloc maintainer"() {
when:
when:
def insertResponse = syncUpdate(new SyncUpdate(data: """\
inetnum: 192.0.0.0 - 192.0.0.255
netname: RIPE-NCC
Expand Down
Loading