use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testViewAddresses.
@Test
public void testViewAddresses() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewAddresses("4444-4444-4444-4447");
assertNotNull(response);
Addresses addresses = (Addresses) response.getEntity();
assertNotNull(addresses);
assertEquals("/4444-4444-4444-4447/address", addresses.getPath());
Utils.verifyLastModified(addresses.getLastModifiedDate());
assertNotNull(addresses.getAddress());
assertEquals(3, addresses.getAddress().size());
for (Address address : addresses.getAddress()) {
Utils.verifyLastModified(address.getLastModifiedDate());
assertThat(address.getPutCode(), anyOf(is(2L), is(3L), is(4L)));
assertThat(address.getCountry().getValue(), anyOf(is(Iso3166Country.CR), is(Iso3166Country.US)));
if (address.getPutCode() == 2L) {
assertEquals(Visibility.PUBLIC, address.getVisibility());
assertEquals("4444-4444-4444-4447", address.getSource().retrieveSourcePath());
} else if (address.getPutCode() == 3L) {
assertEquals(Visibility.LIMITED, address.getVisibility());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
} else if (address.getPutCode() == 4L) {
assertEquals(Visibility.PRIVATE, address.getVisibility());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
}
}
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testReadPublicScope_Address.
@Test
public void testReadPublicScope_Address() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewAddresses(ORCID);
assertNotNull(r);
assertEquals(Addresses.class.getName(), r.getEntity().getClass().getName());
Addresses a = (Addresses) r.getEntity();
assertNotNull(a);
assertEquals("/0000-0000-0000-0003/address", a.getPath());
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());
boolean found9 = false, found10 = false, found11 = false;
for (Address address : a.getAddress()) {
if (address.getPutCode() == 9) {
found9 = true;
} else if (address.getPutCode() == 10) {
found10 = true;
} else if (address.getPutCode() == 11) {
found11 = true;
} else {
fail("Invalid put code " + address.getPutCode());
}
}
assertTrue(found9);
assertTrue(found10);
assertTrue(found11);
r = serviceDelegator.viewAddress(ORCID, 9L);
assertNotNull(r);
assertEquals(Address.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source should work
serviceDelegator.viewAddress(ORCID, 10L);
try {
// Limited am not the source should fail
serviceDelegator.viewAddress(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source should work
serviceDelegator.viewAddress(ORCID, 11L);
try {
// Private am not the source should fail
serviceDelegator.viewAddress(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testViewLimitedAddress.
@Test
public void testViewLimitedAddress() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4447", 3L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
assertEquals("/4444-4444-4444-4447/address/3", address.getPath());
Utils.verifyLastModified(address.getLastModifiedDate());
assertEquals(Visibility.LIMITED, address.getVisibility());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
assertEquals(Iso3166Country.CR, address.getCountry().getValue());
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testUpdateAddressChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateAddressChangingVisibilityTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
assertEquals(Visibility.PUBLIC, address.getVisibility());
address.setVisibility(Visibility.PRIVATE);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
fail();
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testUpdateAddressLeavingVisibilityNullTest.
@Test
public void testUpdateAddressLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
assertEquals(Visibility.PUBLIC, address.getVisibility());
address.setVisibility(null);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
address = (Address) response.getEntity();
assertNotNull(address);
assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Aggregations