26. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/8/2017 1:33:40 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

26.1 Files compared

# Location File Last Modified
1 PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\test\java\gov\va\med\fee\service\impl AuthenticatorServiceImplTest.java Fri Dec 8 17:51:36 2017 UTC
2 PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\test\java\gov\va\med\fee\service\impl AuthenticatorServiceImplTest.java Fri Dec 8 18:30:15 2017 UTC

26.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 8 382
Changed 7 14
Inserted 0 0
Removed 0 0

26.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

26.4 Active regular expressions

No regular expressions were active.

26.5 Comparison detail

  1   package go v.va.med.f ee.service .impl;
  2  
  3   import sta tic org.ha mcrest.Cor eMatchers. equalTo;
  4   import sta tic org.ju nit.Assert .assertTha t;
  5  
  6   import jav a.util.Arr ayList;
  7   import jav a.util.Dat e;
  8   import jav a.util.Has hSet;
  9   import jav a.util.Lis t;
  10   import jav a.util.Set ;
  11  
  12   import org .junit.Ass ert;
  13   import org .junit.Bef ore;
  14   import org .junit.Tes t;
  15   import org .junit.run ner.RunWit h;
  16   import org .mockito.M ock;
  17   import org .mockito.M ockito;
  18   import org .mockito.r unners.Moc kitoJUnitR unner;
  19  
  20   import gov .va.med.do main.fee.A ppRole;
  21   import gov .va.med.do main.fee.A ppUser;
  22   import gov .va.med.do main.fee.S soAuthenti cation;
  23   import gov .va.med.do main.fee.U serRoleUsa ges;
  24   import gov .va.med.do main.fee.U serRoleUsa gesId;
  25   import gov .va.med.do main.fee.V aFacility;
  26   import gov .va.med.fe e.dao.IApp UserReposi tory;
  27   import gov .va.med.fe e.dao.IAut henticator Repository ;
  28   import gov .va.med.fe e.exceptio ns.Generic Exception;
  29   import gov .va.med.fe e.model.re sponse.Use rRoles;
  30   import gov .va.med.fe e.service. impl.Authe nticatorSe rviceImpl;
  31  
  32   /**
  33    * @author  Eyuel Tad dese
  34    *
  35    */
  36  
  37   @RunWith(M ockitoJUni tRunner.cl ass)
  38   public cla ss Authent icatorServ iceImplTes t {
  39  
  40           @M ock
  41           pr ivate Auth enticatorS erviceImpl  authentic atorServic e;
  42  
  43           @M ock
  44           pr ivate IAut henticator Repository  authentic atorReposi tory;
  45  
  46           @M ock
  47           pr ivate IApp UserReposi tory appUs erReposito ry;
  48  
  49           /* *
  50            *  
  51            * /
  52           @B efore
  53           pu blic void  setup() {
  54                    auth enticatorS ervice = n ew Authent icatorServ iceImpl();
  55  
  56                    auth enticatorR epository  = Mockito. mock(IAuth enticatorR epository. class);
  57                    appU serReposit ory = Mock ito.mock(I AppUserRep ository.cl ass);
  58  
  59                    auth enticatorS ervice.set Authentica torDAO(aut henticator Repository );
  60                    auth enticatorS ervice.set AppUserRol eRepositor y(appUserR epository) ;
  61           }
  62  
  63           @T est
  64           pu blic void  testMockIs Working()  {
  65                    Asse rt.assertN otNull("Au thenticato r Service  Injection  Failed", a uthenticat orService) ;
  66                    Asse rt.assertN otNull("Ap pUserRepos itory Inje ction fail ed", appUs erReposito ry);
  67                    Asse rt.assertN otNull("Au thenticato r Reposito ry failed" , authenti catorRepos itory);
  68           }
  69  
  70           @T est
  71           pu blic void  testgetUse rnameFromA spAuth() t hrows Exce ption {
  72                    // S etup
  73                    List <SsoAuthen tication>  ssoauthent ications =  new Array List<>();
  74                     ssoauthent ications.a dd(new Sso Authentica tion(" DN S      AAA", "222 2", "VHAIS USERNAME2" ));
  75  
  76                    // S tub
  77                     Mockito.wh en(authent icatorRepo sitory.fin dByGuid(" DN S      AAA")).the nReturn(ss oauthentic ations);
  78                    try  {
  79                              String use rName = au thenticato rService.g etUsername FromAspAut h(" DN S      AAA");
  80                             assert That(userN ame, equal To("VHAISU SERNAME2") );
  81                              Mockito.ve rify(authe nticatorRe pository,  Mockito.ti mes(1)).fi ndByGuid(" DN S      AAA");
  82                    } ca tch (Excep tion e) {
  83                             Assert .fail("Get UserNameFr omAspAuth( ) failed e xception t hrown");
  84                    }
  85           }
  86  
  87           @T est
  88           pu blic void  testAuthen ticate() {
  89                    // S etup
  90                    List <SsoAuthen tication>  ssoauthent ications =  new Array List<>();
  91                    ssoa uthenticat ions.add(n ew SsoAuth entication ("23456",  "2222", "V HAISUSERNA ME2"));
  92  
  93                    List <AppUser>  appUsers =  new Array List<>();
  94                    Set< UserRoleUs ages> user Roles = ne w HashSet< >();
  95  
  96                    // U ser named  Alvin
  97                    AppU ser appUse r = new Ap pUser();
  98                    appU ser.setApp UserId(Lon g.valueOf( 1));
  99                    appU ser.setUse rName("VHA ISUSERNAME 2");
  100                    appU ser.setFir stName("Al vin");
  101                    appU ser.setLas tName("Sto ne");
  102  
  103                    // R ole Admin
  104                    AppR ole appRol e1 = new A ppRole();
  105                    appR ole1.setAp pRoleId(Lo ng.valueOf (1));
  106                    appR ole1.setRo leName("AD MIN");
  107                    appR ole1.setDe scription( "Admin can  do everyt hing");
  108  
  109                    // R ole Clerk
  110                    AppR ole appRol e2 = new A ppRole();
  111                    appR ole1.setAp pRoleId(Lo ng.valueOf (2));
  112                    appR ole2.setRo leName("Cl erk");
  113                    appR ole2.setDe scription( "Clerk can  view clai ms");
  114  
  115                    User RoleUsages Id id1 = n ew UserRol eUsagesId( Long.value Of(1), Lon g.valueOf( 1), "VAFAC 001", "Y",  "", new D ate());
  116                    User RoleUsages Id id2 = n ew UserRol eUsagesId( Long.value Of(2), Lon g.valueOf( 1), "VAFAC 001", "Y",  "", new D ate());
  117  
  118                    // E ach Indivi ual Roles
  119                    User RoleUsages  userRole1  = new Use rRoleUsage s(id1, new  VaFacilit y(), appRo le1, appUs er);
  120                    User RoleUsages  userRole2  = new Use rRoleUsage s(id2, new  VaFacilit y(), appRo le2, appUs er);
  121  
  122                    // A dd to the  UserRoleUs ages list  each roles
  123                    user Roles.add( userRole1) ;
  124                    user Roles.add( userRole2) ;
  125  
  126                    // A dd the Set  of Roles  to the use r
  127                    appU ser.setUse rRoleUsage s(userRole s);
  128  
  129                    // S tub
  130                    Mock ito.when(a uthenticat orReposito ry.findByG uid("23456 ")).thenRe turn(ssoau thenticati ons);
  131                    Mock ito.when(a ppUserRepo sitory.fin dByAppUser Name("VHAI SUSERNAME2 ")).thenRe turn(appUs ers);
  132                    try  {
  133                             boolea n authenti cateResult  = authent icatorServ ice.authen ticate("45 bRDDosGfqj ZiScoXdCwQ ==");
  134                             Assert .assertTru e(authenti cateResult );
  135                    } ca tch (Gener icExceptio n u) {
  136                             Assert .fail("Use r Authenti cation fai led");
  137                    }
  138           }
  139  
  140           @T est
  141           pu blic void  when_no_va lidation_e rror_then_ GetUserRol e() {
  142                    // S etup
  143                    List <SsoAuthen tication>  ssoauthent ications =  new Array List<>();
  144                     ssoauthent ications.a dd(new Sso Authentica tion(" DN S      AAA", "222 2", "VHAIS USERNAME2" ));
  145  
  146                    List <AppUser>  appUsers =  new Array List<>();
  147                    Set< UserRoleUs ages> user Roles = ne w HashSet< >();
  148  
  149                    // U ser named  Alvin
  150                    AppU ser appUse r = new Ap pUser();
  151                    appU ser.setApp UserId(Lon g.valueOf( 1));
  152                    appU ser.setUse rName("VHA ISUSERNAME 2");
  153                    appU ser.setFir stName("Al vin");
  154                    appU ser.setLas tName("Sto ne");
  155  
  156                    // R ole Admin
  157                    AppR ole appRol e1 = new A ppRole();
  158                    appR ole1.setAp pRoleId(Lo ng.valueOf (1));
  159                    appR ole1.setRo leName("AD MIN");
  160                    appR ole1.setDe scription( "Admin can  do everyt hing");
  161  
  162                    // R ole Clerk
  163                    AppR ole appRol e2 = new A ppRole();
  164                    appR ole1.setAp pRoleId(Lo ng.valueOf (2));
  165                    appR ole2.setRo leName("Cl erk");
  166                    appR ole2.setDe scription( "Clerk can  view clai ms");
  167  
  168                    User RoleUsages Id id1 = n ew UserRol eUsagesId( Long.value Of(1), Lon g.valueOf( 1), "VAFAC 001", "Y",  "", new D ate());
  169                    User RoleUsages Id id2 = n ew UserRol eUsagesId( Long.value Of(2), Lon g.valueOf( 1), "VAFAC 001", "Y",  "", new D ate());
  170  
  171                    // E ach Indivi ual Roles
  172                    User RoleUsages  userRole1  = new Use rRoleUsage s(id1, new  VaFacilit y(), appRo le1, appUs er);
  173                    User RoleUsages  userRole2  = new Use rRoleUsage s(id2, new  VaFacilit y(), appRo le2, appUs er);
  174  
  175                    // A dd to the  UserRoleUs ages list  each roles
  176                    user Roles.add( userRole1) ;
  177                    user Roles.add( userRole2) ;
  178  
  179                    // A dd the Set  of Roles  to the use r
  180                    appU ser.setUse rRoleUsage s(userRole s);
  181  
  182                    // S tub
  183                     Mockito.wh en(authent icatorRepo sitory.fin dByGuid(" DN S      AAA")).the nReturn(ss oauthentic ations);
  184                    Mock ito.when(a ppUserRepo sitory.fin dByAppUser Name("VHAI SUSERNAME2 ")).thenRe turn(appUs ers);
  185  
  186                    // E xpected Us erRole
  187                    User Roles u1 =  new UserR oles("ADMI N", "Admin  can do ev erything") ;
  188  
  189                    /*
  190                      * try { au thenticato rService.a uthenticat e(" DN S      AAA"); Lis t<UserRole s>
  191                     * u serRoles1  = authenti catorServi ce.getUser Roles(); i f(userRole s1 !=
  192                     * n ull) { Use rRoles use rRole0 = u serRoles1. get(0);
  193                     * A ssert.asse rtThat(use rRole0, eq ualTo(u1)) ; } } catc h(Exceptio n e) {
  194                     * A ssert.fail (e.toStrin g()+
  195                     * " : Exceptio n thrown w hen_no_val idation_er ror_then_G etUserRole "); }
  196                     */
  197           }
  198   }