Ejemplo n.º 1
0
  @Test
  public void testBug54060b() throws Exception {
    String header =
        "Digest username=\"mthornton\", "
            + "realm=\"optrak.com\", "
            + "nonce=\"1351427480964:a01c16fed5168d72a2b5267395a2022e\", "
            + "uri=\"/files\", "
            + "algorithm=MD5, "
            + "response=\"f310c44b87efc0bc0a7aab7096fd36b6\", "
            + "opaque=\"DB85C1A73933A7EB586D10E4BF2924EF\", "
            + "cnonce=\"MHg3ZjA3ZGMwMTUwMTA6NzI2OToxMzUxNDI3NDgw\", "
            + "nc=00000001, "
            + "qop=auth";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);

    Assert.assertEquals("mthornton", result.get("username"));
    Assert.assertEquals("optrak.com", result.get("realm"));
    Assert.assertEquals("1351427480964:a01c16fed5168d72a2b5267395a2022e", result.get("nonce"));
    Assert.assertEquals("/files", result.get("uri"));
    Assert.assertEquals("MD5", result.get("algorithm"));
    Assert.assertEquals("f310c44b87efc0bc0a7aab7096fd36b6", result.get("response"));
    Assert.assertEquals("DB85C1A73933A7EB586D10E4BF2924EF", result.get("opaque"));
    Assert.assertEquals("MHg3ZjA3ZGMwMTUwMTA6NzI2OToxMzUxNDI3NDgw", result.get("cnonce"));
    Assert.assertEquals("00000001", result.get("nc"));
    Assert.assertEquals("auth", result.get("qop"));
  }
Ejemplo n.º 2
0
  @Test
  public void testBug54060a() throws Exception {
    String header =
        "Digest username=\"mthornton\", "
            + "realm=\"optrak.com\", "
            + "nonce=\"1351427243671:c1d6360150712149bae931a3ed7cb498\", "
            + "uri=\"/files/junk.txt\", "
            + "response=\"c5c2410bfc46753e83a8f007888b0d2e\", "
            + "opaque=\"DB85C1A73933A7EB586D10E4BF2924EF\", "
            + "qop=auth, "
            + "nc=00000001, "
            + "cnonce=\"9926cb3c334ede11\"";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);

    Assert.assertEquals("mthornton", result.get("username"));
    Assert.assertEquals("optrak.com", result.get("realm"));
    Assert.assertEquals("1351427243671:c1d6360150712149bae931a3ed7cb498", result.get("nonce"));
    Assert.assertEquals("/files/junk.txt", result.get("uri"));
    Assert.assertEquals("c5c2410bfc46753e83a8f007888b0d2e", result.get("response"));
    Assert.assertEquals("DB85C1A73933A7EB586D10E4BF2924EF", result.get("opaque"));
    Assert.assertEquals("auth", result.get("qop"));
    Assert.assertEquals("00000001", result.get("nc"));
    Assert.assertEquals("9926cb3c334ede11", result.get("cnonce"));
  }
Ejemplo n.º 3
0
  @Test
  public void testNonTokenDirective() throws Exception {
    String header = "Digest user{name=\"test\"";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);
    Assert.assertNull(result);
  }
Ejemplo n.º 4
0
  @Test
  public void testUnclosedQuotedString2() throws Exception {
    String header = "Digest username=\"test\\";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);
    Assert.assertNull(result);
  }
Ejemplo n.º 5
0
  @Test
  public void testEndWithLhex() throws Exception {
    String header = "Digest nc=00000001";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);

    Assert.assertEquals("00000001", result.get("nc"));
  }
Ejemplo n.º 6
0
  @Test
  public void testBug54060c() throws Exception {
    String header = "Digest username=\"mthornton\", qop=auth";

    StringReader input = new StringReader(header);

    Map<String, String> result = HttpParser.parseAuthorizationDigest(input);

    Assert.assertEquals("mthornton", result.get("username"));
    Assert.assertEquals("auth", result.get("qop"));
  }