56. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/2/2017 7:00:31 AM Central Daylight 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.

56.1 Files compared

# Location File Last Modified
1 cds.zip\cds\product\tests\acceptance-tests\features\steps\helper HTTPartyWithBasicAuth.rb Thu Mar 16 15:17:48 2017 UTC
2 cds.zip\cds\product\tests\acceptance-tests\features\steps\helper HTTPartyWithBasicAuth.rb Thu Sep 28 17:25:55 2017 UTC

56.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 610
Changed 2 24
Inserted 0 0
Removed 0 0

56.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

56.4 Active regular expressions

No regular expressions were active.

56.5 Comparison detail

  1   require "h ttparty"
  2  
  3   path = Fil e.expand_p ath '..',  __FILE__
  4   $LOAD_PATH .unshift p ath unless  $LOAD_PAT H.include? (path)
  5   require "D efaultLogi n.rb"
  6   require "T estSupport .rb"
  7   require "D omAccess.r b"
  8   require "P atientPick erDomEleme nts.rb"
  9  
  10   class Test Clients
  11     @@users  = {}
  12  
  13       @@users[" R E D A CTED "] = " REDACTED "
  14       @@users[" REDA C TED "] = " REDACTED "
  15       @@users[" R E D A CTED "] = " REDACTED "
  16       @@users["U nauthorize dUser"] =  " PL        "
  17       @@users["A uditLogUse r"] = " REDACTED "
  18       @@users[" R E D A CTED "] = " REDACTED "
  19       @@users[" R E D A CTED "] = " REDACTED "
  20       @@users[" R E D A CTED "] = "badu ser"
  21       @@users[" R E D A CTED "] = " REDACTED "
  22       @@users[" REDA C TED "] = " REDACTED "
  23       @@users[" R E D A CTED "] = " REDACTED "
  24     def self .password_ for(userna me)
  25       return  @@users[u sername]
  26     end
  27   end
  28  
  29   class HTTP artyWithBa sicAuth
  30     include  HTTParty
  31       @@auth = {  :accessCo de => " REDACTED ", :verify Code => " REDACTED ", :site = > "9E7A",  :division  => "500" }
  32   #remove th is site be fore doing  things
  33     @@site =  nil
  34     @@time_s tart = Tim e.new
  35     @@time_d one = Time .new
  36     @@time_o ut_time =  300
  37     @@cookie  = nil
  38     @@jwt =  nil
  39  
  40     def self .auth
  41       return  @@auth
  42     end
  43  
  44     def self .time_elap sed_last_c all
  45       return  @@time_do ne - @@tim e_start
  46     end
  47  
  48     def self .tokens_re ady
  49       !@@coo kie.nil? | | !@@jwt.n il?
  50     end
  51  
  52     def self .build_opt ions
  53       header s = {}
  54       header s['Cookie' ] = @@cook ie unless  @@cookie.n il?
  55       header s['Authori zation'] =  @@jwt unl ess @@jwt. nil?
  56  
  57       option s = {}
  58       option s[:headers ] = header s
  59       option s[:verify]  = false
  60       option s[:timeout ] = @@time _out_time
  61       return  options
  62     end
  63  
  64     def self .acquire_a uth_detail s(opt)
  65       auth_d etails = { }
  66       if opt [:user] &&  opt[:path ]
  67         auth _details[: accessCode ] = opt.us er.split(' ;')[1]
  68         auth _details[: site] = op t.user.spl it(';')[0]
  69         auth _details[: verifyCode ] = opt.pa ss
  70       end
  71       return  auth_deta ils
  72     end
  73  
  74     #General  login fun ction to a llow for c ookie and  jwt token  storage
  75     def self .acquire_t okens(auth _details =  {})
  76       defaul t_auth = a uth
  77       payloa d = { :acc essCode =>  default_a uth[:acces sCode], :v erifyCode  => default _auth[:ver ifyCode],  :site => d efault_aut h[:site],  :division  => default _auth[:div ision] }.m erge(auth_ details).t o_json
  78  
  79       authen tication_p ath = RDKQ uery.new(' authentica tion-authe ntication' ).path
  80       @respo nse = HTTP arty.post( authentica tion_path,  :body =>  payload, : headers =>  { 'Conten t-Type' =>  'applicat ion/json'  }, :timeou t => @@tim e_out_time , :verify  => false)
  81  
  82       p "HTT PartyWithB asicAuth:  #{payload}  had a #{@ response.c ode} respo nse"
  83       @@cook ie = @resp onse.heade rs['set-co okie']
  84       jwt =  @response. headers['X -Set-JWT']
  85       @@jwt  = 'Bearer  ' + jwt un less jwt.n il?
  86       @@site  = JSON.pa rse(payloa d)[:site]
  87       return  @response
  88     end
  89  
  90     def self .get_authe ntication( auth_detai ls = {})
  91       @respo nse = nil
  92       @respo nse = acqu ire_tokens (auth_deta ils) unles s tokens_r eady
  93       return  @response
  94     end
  95  
  96     def self .get_with_ authorizat ion(path)
  97       auth_r esp = get_ authentica tion
  98       option s = {}
  99       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  100       return  execute_g et(path, o ptions)
  101     end
  102  
  103     def self .post_with _authoriza tion(path)
  104       auth_r esp = get_ authentica tion
  105       option s = {}
  106       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  107       return  execute_p ost(path,  options)
  108     end
  109  
  110     def self .put_with_ authorizat ion(path)
  111       auth_r esp = get_ authentica tion
  112       option s = {}
  113       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  114       return  execute_p ut(path, o ptions)
  115     end
  116  
  117     def self .delete_wi th_authori zation(pat h)
  118       auth_r esp = get_ authentica tion
  119       option s = {}
  120       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  121       return  execute_d elete(path , options)
  122     end
  123  
  124     def self .get_json_ with_autho rization(p ath, json  = {}, head ers = {})
  125       auth_r esp = get_ authentica tion
  126       option s = {}
  127       option s[:body] =  json unle ss json.em pty?
  128       option s[:headers ] = header s unless h eaders.emp ty?
  129       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  130       return  execute_g et(path, o ptions)
  131     end
  132  
  133     def self .post_json _with_auth orization( path, json  = {}, hea ders = {})
  134       auth_r esp = get_ authentica tion
  135       option s = {}
  136       option s[:body] =  json unle ss json.em pty?
  137       option s[:headers ] = header s unless h eaders.emp ty?
  138       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  139       return  execute_p ost(path,  options)
  140     end
  141  
  142     def self .put_json_ with_autho rization(p ath, json  = {}, head ers = {})
  143       auth_r esp = get_ authentica tion
  144       option s = {}
  145       option s[:body] =  json unle ss json.em pty?
  146       option s[:headers ] = header s unless h eaders.emp ty?
  147       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  148       return  execute_p ut(path, o ptions)
  149     end
  150  
  151     def self .delete_js on_with_au thorizatio n(path, js on = {}, h eaders = { })
  152       auth_r esp = get_ authentica tion
  153       option s = {}
  154       option s[:body] =  json unle ss json.em pty?
  155       option s[:headers ] = header s unless h eaders.emp ty?
  156       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  157       return  execute_d elete(path , options)
  158     end
  159  
  160     def self .get_with_ authorizat ion_for_us er(path, u ser, pass,  json = {} , headers  = {})
  161       auth_d etails = { }
  162       auth_d etails[:ac cessCode]  = user.spl it(';')[1]
  163       auth_d etails[:si te] = user .split(';' )[0]
  164       auth_d etails[:ve rifyCode]  = pass
  165       auth_r esp = get_ authentica tion(auth_ details)
  166  
  167       option s = {}
  168       option s[:body] =  json unle ss json.em pty?
  169       option s[:headers ] = header s unless h eaders.emp ty?
  170       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  171       return  execute_g et(path, o ptions)
  172     end
  173  
  174     def self .post_json _with_auth orization_ for_user(p ath, user,  pass, jso n = {}, he aders = {} )
  175       auth_d etails = { }
  176       auth_d etails[:ac cessCode]  = user.spl it(';')[1]
  177       auth_d etails[:si te] = user .split(';' )[0]
  178       auth_d etails[:ve rifyCode]  = pass
  179       auth_r esp = get_ authentica tion(auth_ details)
  180  
  181       option s = {}
  182       option s[:body] =  json unle ss json.em pty?
  183       option s[:headers ] = header s unless h eaders.emp ty?
  184       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  185       return  execute_p ost(path,  options)
  186     end
  187  
  188     def self .put_json_ with_autho rization_f or_user(pa th, user,  pass, json  = {}, hea ders = {})
  189       auth_d etails = { }
  190       auth_d etails[:ac cessCode]  = user.spl it(';')[1]
  191       auth_d etails[:si te] = user .split(';' )[0]
  192       auth_d etails[:ve rifyCode]  = pass
  193       auth_r esp = get_ authentica tion(auth_ details)
  194  
  195       option s = {}
  196       option s[:body] =  json unle ss json.em pty?
  197       option s[:headers ] = header s unless h eaders.emp ty?
  198       option s[:respons e] = auth_ resp unles s auth_res p.nil?
  199       return  execute_p ut(path, o ptions)
  200     end
  201  
  202     ######## ########## ########## ########## #
  203     # These  calls are  used by th e above fu nctions af ter a user  has been  establishe d
  204     # Trying  to use th em without  a user wi ll likely  cause a 40 1 due to t he missing  
  205     # cookie  or jwt to kens
  206     ######## ########## ########## ########## ##
  207     def self .execute_g et(path, o pt = {})
  208       p "GET  " + path
  209       @respo nse = nil
  210  
  211       return  opt[:resp onse] if o pt.key?('r esponse'.t o_sym) &&  opt[:respo nse].code  != 200
  212  
  213       option s = deep_m erge(build _options,  opt)
  214       #p "Op tions; #{o ptions}"
  215       begin
  216         @@ti me_start =  Time.new
  217         begi n
  218           @r esponse =  HTTParty.g et(path, o ptions)
  219         resc ue Excepti on => e
  220           p  "Exception : #{e}"
  221         end
  222         @@ti me_done =  Time.new
  223         log_ id = @resp onse.heade rs['logid' ]
  224         p "l ogId: #{lo g_id}" if  log_id
  225       rescue  Exception  => e
  226         @@ti me_done =  Time.new
  227         p "T ime to fai lure: #{ti me_elapsed _last_call }"
  228         rais e e, "Time  to failur e: #{time_ elapsed_la st_call}"
  229       end
  230       return  @response
  231     end
  232  
  233     def self .execute_p ost(path,  opt = {})
  234       p "POS T " + path
  235       @respo nse = nil
  236  
  237       return  opt[:resp onse] if o pt.key?('r esponse'.t o_sym) &&  opt[:respo nse].code  != 200
  238  
  239       option s = deep_m erge(build _options,  opt)
  240       #p "Op tions; #{o ptions}"
  241       begin
  242         @@ti me_start =  Time.new
  243         begi n
  244           @r esponse =  HTTParty.p ost(path,  options)
  245         resc ue Excepti on => e
  246           p  "Exception : #{e}"
  247         end
  248         @@ti me_done =  Time.new
  249         log_ id = @resp onse.heade rs['logid' ]
  250         p "l ogId: #{lo g_id}" if  log_id
  251       rescue  Exception  => e
  252         @@ti me_done =  Time.new
  253         p "T ime to fai lure: #{ti me_elapsed _last_call }"
  254         rais e e, "Time  to failur e: #{time_ elapsed_la st_call}"
  255       end
  256       return  @response
  257     end
  258  
  259     def self .execute_p ut(path, o pt = {})
  260       p "PUT  " + path
  261       @respo nse = nil
  262  
  263       return  opt[:resp onse] if o pt.key?('r esponse'.t o_sym) &&  opt[:respo nse].code  != 200
  264  
  265       option s = deep_m erge(build _options,  opt)
  266       #p "Op tions; #{o ptions}"
  267       begin
  268         @@ti me_start =  Time.new
  269         begi n
  270           @r esponse =  HTTParty.p ut(path, o ptions)
  271         resc ue Excepti on => e
  272           p  "Exception : #{e}"
  273         end
  274         @@ti me_done =  Time.new
  275         log_ id = @resp onse.heade rs['logid' ]
  276         p "l ogId: #{lo g_id}" if  log_id
  277       rescue  Exception  => e
  278         @@ti me_done =  Time.new
  279         p "T ime to fai lure: #{ti me_elapsed _last_call }"
  280         rais e e, "Time  to failur e: #{time_ elapsed_la st_call}"
  281       end
  282       return  @response
  283     end
  284  
  285     def self .execute_d elete(path , opt = {} )
  286       p "DEL ETE " + pa th
  287       @respo nse = nil
  288  
  289       return  opt[:resp onse] if o pt.key?('r esponse'.t o_sym) &&  opt[:respo nse].code  != 200
  290  
  291       option s = deep_m erge(build _options,  opt)
  292       #p "Op tions; #{o ptions}"
  293       begin
  294         @@ti me_start =  Time.new
  295         begi n
  296           @r esponse =  HTTParty.d elete(path , options)
  297         resc ue Excepti on => e
  298           p  "Exception : #{e}"
  299         end
  300         @@ti me_done =  Time.new
  301         log_ id = @resp onse.heade rs['logid' ]
  302         p "l ogId: #{lo g_id}" if  log_id
  303       rescue  Exception  => e
  304         @@ti me_done =  Time.new
  305         p "T ime to fai lure: #{ti me_elapsed _last_call }"
  306         rais e e, "Time  to failur e: #{time_ elapsed_la st_call}"
  307       end
  308       @@cook ie = nil i f path <=>  '/resourc e/authenti cation'
  309       @@jwt  = nil if p ath <=> '/ resource/a uthenticat ion'
  310       return  @response
  311     end
  312   end
  313  
  314   def deep_m erge(first , second)
  315     merger =  proc { |k ey, v1, v2 | (v1.is_a ? Hash) &&  (v2.is_a?  Hash) ? v 1.merge(v2 , &merger)  : v2 }
  316     first.me rge(second , &merger)
  317   end