/**
   * Gets the credentials2.
   *
   * @return the credentials2
   * @throws Exception the exception
   */
  @Test
  public void getCredentials2() throws Exception {
    WebSocket websocket = Mockito.mock(WebSocket.class);

    DigestAuthenticator digestAuthenticator = new DigestAuthenticator();
    digestAuthenticator = PowerMockito.spy(digestAuthenticator);
    PowerMockito.when(digestAuthenticator, "generateCnonce").thenReturn("0a4f113b");

    DefaultAuthenticator authenticator =
        new DefaultAuthenticator(new BasicAuthenticator(), digestAuthenticator, null);
    authenticator.init(websocket, new Credentials("Mufasa", "Circle Of Life"));

    HttpHeader header = new HttpHeader();
    header.addHeader("Proxy-Authenticate", "Basic realm=\"[email protected]\"");
    header.addHeader(
        "Proxy-Authenticate",
        "Digest realm=\"[email protected]\", qop=\"auth,auth-int\", nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"");
    Assert.assertEquals(
        "Digest username=\"Mufasa\", realm=\"[email protected]\", nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", uri=\"/dir/index.html\", qop=auth, nc=00000001, cnonce=\"0a4f113b\", opaque=\"5ccc069c403ebaf9f0171e9517f40e41\", response=\"6629fae49393a05397450978507c4ef1\"",
        authenticator.getCredentials("GET", "/dir/index.html", header, "Proxy-Authenticate"));
  }
  /**
   * Gets the credentials1.
   *
   * @return the credentials1
   * @throws Exception the exception
   */
  @Test
  public void getCredentials1() throws Exception {
    WebSocket websocket = Mockito.mock(WebSocket.class);

    DigestAuthenticator digestAuthenticator = new DigestAuthenticator();
    digestAuthenticator = PowerMockito.spy(digestAuthenticator);
    PowerMockito.when(digestAuthenticator, "generateCnonce").thenReturn("0a4f113b");

    DefaultAuthenticator authenticator =
        new DefaultAuthenticator(new BasicAuthenticator(), digestAuthenticator, null);
    authenticator.init(websocket, new Credentials("Mufasa", "Circle Of Life"));

    HttpHeader header = new HttpHeader();
    header.addHeader("Proxy-Authenticate", "Basic realm=\"[email protected]\"");
    Assert.assertEquals(
        "Basic TXVmYXNhOkNpcmNsZSBPZiBMaWZl",
        authenticator.getCredentials("CONNECT", "host:8080", header, "Proxy-Authenticate"));
  }