-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dbf 70 references api doesnt handle multiple (#404)
* Basic fix for missing auth attribute in old mntner objects causing deletion problem * now uses a property map instead of single named properties * fixed property * property missing from test properties file * fixed possible null pointer exception * missed a final * do not need to substitute '-' by using literals as keys in properties * will cater for identical values when dummifying * corrected formatting * typo * ignored test now passes, removing ignore
- Loading branch information
Rob Miller
authored
Sep 14, 2016
1 parent
f5b3615
commit 719afdb
Showing
2 changed files
with
99 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,11 +307,11 @@ public void update_create_multiple_objects_successfully() { | |
public void update_create_multiple_objects_and_delete_successfully() { | ||
final RpslObject firstPerson = RpslObject.parse( | ||
"person: Test Person\n" + | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TP2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TP2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
final RpslObject secondPerson = RpslObject.parse( | ||
"person: Test Person\n" + | ||
"address: Singel 258\n" + | ||
|
@@ -353,12 +353,12 @@ public void update_create_multiple_objects_and_delete_successfully() { | |
public void update_modify_with_sso_auth_succeeds() { | ||
final RpslObject ssomnt = RpslObject.parse( | ||
"mntner: SSO-MNT\n" + | ||
"descr: Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: SSO [email protected]\n" + | ||
"mnt-by: SSO-MNT\n" + | ||
"source: TEST"); | ||
"descr: Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: SSO [email protected]\n" + | ||
"mnt-by: SSO-MNT\n" + | ||
"source: TEST"); | ||
|
||
//databaseHelper.addObject does not translate account to UUID, so we do it via classic REST @POST | ||
RestTest.target(getPort(), "whois/test/mntner") | ||
|
@@ -388,12 +388,12 @@ public void update_modify_with_sso_auth_succeeds() { | |
public void update_delete_with_sso_auth_succeeds() { | ||
final RpslObject ssomnt = RpslObject.parse( | ||
"mntner: SSO-MNT\n" + | ||
"descr: Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: SSO [email protected]\n" + | ||
"mnt-by: SSO-MNT\n" + | ||
"source: TEST"); | ||
"descr: Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: SSO [email protected]\n" + | ||
"mnt-by: SSO-MNT\n" + | ||
"source: TEST"); | ||
|
||
//databaseHelper.addObject does not translate account to UUID, so we do it via classic REST @POST | ||
RestTest.target(getPort(), "whois/test/mntner") | ||
|
@@ -535,13 +535,13 @@ public void update_modify_multiple_objects_success() { | |
"source: TEST"); | ||
final RpslObject updatedRole = RpslObject.parse( | ||
"role: Test Role\n" + | ||
"address: Singel 258\n" + | ||
"e-mail: [email protected]\n" + | ||
"remarks: updated role\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR1-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"address: Singel 258\n" + | ||
"e-mail: [email protected]\n" + | ||
"remarks: updated role\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR1-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
|
||
final WhoisResources response = RestTest.target(getPort(), "whois/references/test") | ||
.queryParam("override", SyncUpdateUtils.encode("personadmin,secret,reason")) | ||
|
@@ -789,7 +789,6 @@ public void delete_pair_using_sso_returns_original_state_of_objects_in_response( | |
new Attribute("mnt-by", "SSO-MNT", null, "mntner", Link.create("http://rest-test.db.ripe.net/test/mntner/SSO-MNT")))); | ||
} | ||
|
||
@Ignore("[ES] TODO multiple references to person not handled properly") | ||
@Test | ||
public void delete_mntner_person_pair_multiple_references() { | ||
databaseHelper.addObject( | ||
|
@@ -800,11 +799,13 @@ public void delete_mntner_person_pair_multiple_references() { | |
databaseHelper.addObject( | ||
"mntner: DUMMY-MNT\n" + | ||
"descr: Startup maintainer\n" + | ||
"auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + | ||
"upd-to: [email protected]\n" + | ||
"admin-c: AP1-TEST\n" + | ||
"mnt-by: DUMMY-MNT\n" + | ||
"admin-c: AP1-TEST\n" + | ||
"tech-c: AP1-TEST\n" + | ||
"source: RIPE"); | ||
"source: TEST"); | ||
databaseHelper.updateObject( | ||
"person: Another Person\n" + | ||
"nic-hdl: AP1-TEST\n" + | ||
|
@@ -831,11 +832,11 @@ public void delete_object_multiple_references_succeeds() { | |
|
||
databaseHelper.addObject( | ||
"role: Test Role\n" + | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
|
||
final WhoisResources whoisResources = RestTest.target(getPort(), "whois/references/TEST/mntner/OWNER-MNT?password=test") | ||
.request(MediaType.APPLICATION_JSON_TYPE) | ||
|
@@ -853,11 +854,11 @@ public void delete_object_multiple_references_succeeds() { | |
public void delete_object_with_outgoing_references_only() { | ||
databaseHelper.addObject( | ||
"role: Test Role\n" + | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
|
||
final WhoisResources whoisResources = RestTest.target(getPort(), "whois/references/TEST/role/TR2-TEST?password=test") | ||
.request() | ||
|
@@ -873,11 +874,11 @@ public void delete_object_with_outgoing_references_only() { | |
public void delete_object_with_outgoing_references_only_fails() { | ||
databaseHelper.addObject( | ||
"role: Test Role\n" + | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"address: Singel 258\n" + | ||
"phone: +31 6 12345678\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
|
||
try { | ||
RestTest.target(getPort(), "whois/references/TEST/role/TR2-TEST") | ||
|
@@ -902,12 +903,12 @@ public void delete_object_with_outgoing_references_only_fails() { | |
public void delete_non_mntner_or_role() { | ||
databaseHelper.addObject( | ||
"organisation: ORG-TO1-TEST\n" + | ||
"org-type: other\n" + | ||
"org-name: First Org\n" + | ||
"address: RIPE NCC\n" + | ||
"e-mail: [email protected]\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
"org-type: other\n" + | ||
"org-name: First Org\n" + | ||
"address: RIPE NCC\n" + | ||
"e-mail: [email protected]\n" + | ||
"mnt-by: OWNER-MNT\n" + | ||
"source: TEST"); | ||
try { | ||
RestTest.target(getPort(), "whois/references/TEST/organisation/ORG-TO1-TEST?password=test") | ||
.request() | ||
|
@@ -926,12 +927,12 @@ public void delete_non_mntner_or_role() { | |
public void delete_mntner_fails_person_referenced_from_another_mntner() { | ||
databaseHelper.addObject( | ||
"mntner: ANOTHER-MNT\n" + | ||
"descr: Another Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
"descr: Another Maintainer\n" + | ||
"admin-c: TP1-TEST\n" + | ||
"upd-to: [email protected]\n" + | ||
"auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
|
||
final Response response = RestTest.target(getPort(), "whois/references/TEST/mntner/OWNER-MNT") | ||
.request() | ||
|
@@ -1018,6 +1019,41 @@ public void delete_person_mnter_pair_with_override() { | |
assertThat(objectExists(ObjectType.PERSON, "TP2-TEST"), is(false)); | ||
} | ||
|
||
@Test | ||
public void delete_person_mnter_pair_with_override_duplicate_adminc() { | ||
databaseHelper.addObject( | ||
"mntner: ANOTHER-MNT\n" + | ||
"auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + | ||
"upd-to: [email protected]\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
databaseHelper.addObject( | ||
"person: Test Person2\n" + | ||
"nic-hdl: TP2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
databaseHelper.updateObject( | ||
"mntner: ANOTHER-MNT\n" + | ||
"auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + | ||
"upd-to: [email protected]\n" + | ||
"admin-c: TP2-TEST\n" + | ||
"admin-c: TP2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
|
||
assertThat(objectExists(ObjectType.MNTNER, "ANOTHER-MNT"), is(true)); | ||
assertThat(objectExists(ObjectType.PERSON, "TP2-TEST"), is(true)); | ||
|
||
RestTest.target(getPort(), "whois/references/TEST/mntner/ANOTHER-MNT") | ||
.queryParam("override", "personadmin,secret,reason") | ||
.request() | ||
.delete(); | ||
|
||
assertThat(objectExists(ObjectType.MNTNER, "ANOTHER-MNT"), is(false)); | ||
assertThat(objectExists(ObjectType.PERSON, "TP2-TEST"), is(false)); | ||
} | ||
|
||
|
||
@Test | ||
public void delete_person_mnter_pair_with_override_bad_password() { | ||
databaseHelper.addObject( | ||
|
@@ -1124,18 +1160,18 @@ public void delete_role_mnter_pair_with_override_missing_mandatory_attribute_not | |
// upd-to: not in map. no maintainers in db missing this mandatory attr, always been mandatory so should never be missing? | ||
databaseHelper.addObject( | ||
"mntner: ANOTHER-MNT\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
databaseHelper.addObject( | ||
"role: Test Role2\n" + | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
"nic-hdl: TR2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
databaseHelper.updateObject( | ||
"mntner: ANOTHER-MNT\n" + | ||
"admin-c: TR2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
"admin-c: TR2-TEST\n" + | ||
"mnt-by: ANOTHER-MNT\n" + | ||
"source: TEST"); | ||
|
||
assertThat(objectExists(ObjectType.MNTNER, "ANOTHER-MNT"), is(true)); | ||
assertThat(objectExists(ObjectType.ROLE, "TR2-TEST"), is(true)); | ||
|