• Stephen.lordson
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
In the below code,   the code coverage is only 66% . it is covering for try and catch block but not covering for IF AND ELSE block . I am looking for your help

complete code.
--------------
public class MyClassTest{
    public String accountName{get;set;}
 
    public void aMethod(){
        try{
            Account a = [SELECT id FROM Account WHERE name = :accountName];
            if(a.Id=='2'){
            accountName = 'A name that I know ';
            }else{
            accountName = 'A name ';}
        } catch (System.queryException e){
             accountName = 'A name that I know doesn\'t exist in my real dataset';
        }
    }

public static testMethod void  testAMethod1(){    
   test.startTest();
    MyClassTest mc = new MyClassTest();
    mc.accountName = 'A name that I know doesn\'t exist in my real dataset';
    mc.aMethod();
    List<Account> a = [SELECT id FROM Account WHERE name = 'A name that I know doesn\'t exist in my real dataset'];
    System.assert(a.size()>0);
    test.stopTest();
}
}
 

Dear all,

 

We just got our security testing results, got one issue 

 

Scanning File: \TestHelp.page

61 window.location.href='https://help.salesforce.com/htviewhelpdoc?id='+'{!JSENCODE(temp)}'+'&siteLang=en_US';

 

Recommendation:

Ensure that all session IDs are unique, random and encrypted.

Ensure that unencrypted session IDs are not used in the URL.

Make sure all tokens, session IDs and session cookies expire after a reasonable time period.

 

the id part already encoded with json encode , we didn get any exception in code scanner. Could any one suggest wht could be the solution for code  at line 61.

 

Thnaks,

Stephen

 

 

Dear all,

 

We just got our security testing results, got one issue 

 

Scanning File: \TestHelp.page

61 window.location.href='https://help.salesforce.com/htviewhelpdoc?id='+'{!JSENCODE(temp)}'+'&siteLang=en_US';

 

Recommendation:

Ensure that all session IDs are unique, random and encrypted.

Ensure that unencrypted session IDs are not used in the URL.

Make sure all tokens, session IDs and session cookies expire after a reasonable time period.

 

the id part already encoded with json encode , we didn get any exception in code scanner. Could any one suggest wht could be the solution for code  at line 61.

 

Thnaks,

Stephen