use of gov.cms.dpc.api.auth.OrganizationPrincipal in project dpc-app by CMSgov.
the class EndpointResourceUnitTest method testCreateEndpointWithManagingOrganizationMismatch.
@Test
public void testCreateEndpointWithManagingOrganizationMismatch() {
UUID orgId = UUID.randomUUID();
Organization organization = new Organization();
organization.setId(orgId.toString());
OrganizationPrincipal organizationPrincipal = new OrganizationPrincipal(organization);
Endpoint endpoint = new Endpoint();
endpoint.setManagingOrganization(new Reference("Organization/" + UUID.randomUUID()));
assertThrows(WebApplicationException.class, () -> resource.createEndpoint(organizationPrincipal, endpoint));
}
use of gov.cms.dpc.api.auth.OrganizationPrincipal in project dpc-app by CMSgov.
the class PractitionerResourceUnitTest method testSubmitProvider.
@Test
public void testSubmitProvider() {
UUID orgId = UUID.randomUUID();
Organization organization = new Organization();
organization.setId(orgId.toString());
OrganizationPrincipal organizationPrincipal = new OrganizationPrincipal(organization);
Practitioner practitioner = new Practitioner();
ICreateTyped createExec = Mockito.mock(ICreateTyped.class);
Mockito.when(attributionClient.create().resource(practitioner).encodedJson()).thenReturn(createExec);
MethodOutcome outcome = new MethodOutcome();
outcome.setResource(practitioner);
Mockito.when(createExec.execute()).thenReturn(outcome);
Response response = resource.submitProvider(organizationPrincipal, practitioner);
Practitioner result = (Practitioner) response.getEntity();
assertEquals(practitioner, result);
assertEquals("Organization ID", practitioner.getMeta().getTag(DPCIdentifierSystem.DPC.getSystem(), orgId.toString()).getDisplay());
}
use of gov.cms.dpc.api.auth.OrganizationPrincipal in project dpc-app by CMSgov.
the class ListClientTokens method execute.
@Override
public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception {
final Organization organization = extractOrganization(parameters);
final CollectionResponse<TokenEntity> organizationTokens = this.resource.getOrganizationTokens(new OrganizationPrincipal(organization));
this.mapper.writeValue(output, organizationTokens);
}
use of gov.cms.dpc.api.auth.OrganizationPrincipal in project dpc-app by CMSgov.
the class ListPublicKeys method execute.
@Override
public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception {
final Organization organization = extractOrganization(parameters);
final CollectionResponse<PublicKeyEntity> publicKeys = this.resource.getPublicKeys(new OrganizationPrincipal(organization));
this.mapper.writeValue(output, publicKeys);
}
use of gov.cms.dpc.api.auth.OrganizationPrincipal in project dpc-app by CMSgov.
the class DeleteToken method execute.
@Override
public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) {
final Organization organization = extractOrganization(parameters);
final ImmutableCollection<String> tokenCollection = parameters.get("token");
if (tokenCollection.isEmpty()) {
throw new WebApplicationException("Must have token", Response.Status.BAD_REQUEST);
}
final String tokenID = tokenCollection.asList().get(0);
this.resource.deleteOrganizationToken(new OrganizationPrincipal(organization), UUID.fromString(tokenID));
}
Aggregations