Package org.owasp.passfault

Examples of org.owasp.passfault.PasswordAnalysis


   */
  @Test
  public void testGetChars() {
    System.out.println("getChars");

    BackwardsAnalysisAdapter instance = new BackwardsAnalysisAdapter(new PasswordAnalysis("backwards"));
    CharSequence expResult = new StringBuilder("backwards").reverse().toString();
    CharSequence result = instance.getCharSequence();
    assertEquals(expResult, result);
  }


  @Test
  public void testAdaptedBackwards() {
    System.out.println("testAdaptedBackwards");

    {
      BackwardsAnalysisAdapter instance = new BackwardsAnalysisAdapter(new PasswordAnalysis(
          "012drow78"));
      //reversed would be= 87word210
      //it would find 'word' at index 2

      int reverseStartingIndex = 2;
      int actualStartingIndex = 3;
      assertAdaptedReverse(instance, reverseStartingIndex, actualStartingIndex);
    }
    {
      BackwardsAnalysisAdapter instance = new BackwardsAnalysisAdapter(new PasswordAnalysis(
          "012drow"));
      //reversed would be= word210
      //it would find 'word' at index 0

      int reverseStartingIndex = 0;
      int actualStartingIndex = 3;
      assertAdaptedReverse(instance, reverseStartingIndex, actualStartingIndex);
    }
    {
      BackwardsAnalysisAdapter instance = new BackwardsAnalysisAdapter(new PasswordAnalysis(
          "drow78"));
      //reversed would be= 87word
      //it would find 'word' at index 2

      int reverseStartingIndex = 2;

    //the above works in tomcat but not jetty or google app engine
    //the below works in jetty and google app engine but not tomcat
    SecureString password = getPassword(request.getInputStream(), request.getContentLength());
    CompositeFinder finder = getCompositeFinder();
    try{
      PasswordAnalysis analysis = new PasswordAnalysis(password);
      try {
        finder.analyze(analysis);
        finder.waitForAnalysis(analysis);
      } catch (Exception e) {
        throw new ServletException(e);

     * Test of analyze method, of class KeySequenceFinder.
     */
    @Test
    public void testAnalyze_right() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("asdfg");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(6, count);
    }

     * Test of analyze method, of class KeySequenceFinder.
     */
    @Test
    public void testAnalyze_rightMixed() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("aSdFg");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(6, count);
    }

    }
   
    @Test
    public void testAnalyze_left() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("[poi");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(3, count);
    }

    }
   
    @Test
    public void testAnalyze_upperleft() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("zaq1");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(3, count);
    }

    }
   
    @Test
    public void testAnalyze_upperright() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("zse4");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(3, count);
    }

        assertEquals(3, count);
    }
    @Test
    public void testAnalyze_lowerleft() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("4esz");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(3, count);
    }

    }
   
    @Test
    public void testAnalyze_lowerright() throws Exception {
        System.out.println("analyze");
        PasswordAnalysis pass = new PasswordAnalysis("1qaz");
        KeySequenceFinder instance = new KeySequenceFinder(new EnglishKeyBoard());
        instance.analyze(pass);
        int count = pass.getPossiblePatternCount();
        assertEquals(3, count);
    }

TOP

Related Classes of org.owasp.passfault.PasswordAnalysis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.