View Javadoc
1   /*
2    * Copyright 2017 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.core.atna;
17  
18  import org.junit.Test;
19  import org.openehealth.ipf.commons.ihe.core.atna.custom.HpdAuditor;
20  import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes;
21  import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes;
22  
23  import java.util.Arrays;
24  import java.util.List;
25  
26  import static org.junit.Assert.assertEquals;
27  
28  /**
29   * @author Dmytro Rud
30   */
31  public class HpdAuditorTest extends OhtAuditorTestBase {
32  
33      private static final List<String> PROVIDER_IDS = Arrays.asList(
34              "2.16.10.89.200:UPIN:800-800-8000:Active",
35              "2.16.10.98.123:NPI:666789-800:Active",
36              "1.89.11.00.123:HospId:786868:Active");
37  
38      @Test
39      public void testAuditors() {
40          final HpdAuditor auditor = AuditorManager.getHpdAuditor();
41  
42          // operation ADD
43          auditor.auditIti59(true,
44                  RFC3881EventCodes.RFC3881EventActionCodes.CREATE,
45                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
46                  PROVIDER_IDS,
47                  null, null,
48                  PURPOSES_OF_USE,
49                  USER_ROLES);
50  
51          auditor.auditIti59(false,
52                  RFC3881EventCodes.RFC3881EventActionCodes.CREATE,
53                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
54                  PROVIDER_IDS,
55                  null, null,
56                  PURPOSES_OF_USE,
57                  USER_ROLES);
58  
59          // operation DELETE
60          auditor.auditIti59(true,
61                  RFC3881EventCodes.RFC3881EventActionCodes.DELETE,
62                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
63                  null,
64                  "uid=john.doe,ou=People,dc=example,dc=com",
65                  null,
66                  PURPOSES_OF_USE,
67                  USER_ROLES);
68  
69          // operation MODIFY DN
70          auditor.auditIti59(true,
71                  RFC3881EventCodes.RFC3881EventActionCodes.UPDATE,
72                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
73                  null,
74                  "uid=john.doe,ou=People,dc=example,dc=com",
75                  "cn=John Doe+telephoneNumber=+1 123-456-7890",
76                  PURPOSES_OF_USE,
77                  USER_ROLES);
78  
79          assertEquals(4, sender.getMessages().size());
80      }
81  
82  }