@Test
    void testNoNextNonceUsageFromContext() throws Exception {
        final HttpRequest request = new BasicHttpRequest("GET", "/");
        final HttpHost host = new HttpHost("somehost", 80);
        final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create()
                .add(new AuthScope(host, "realm1", null), "username", "password".toCharArray())
                .build();

        final HttpClientContext context = HttpClientContext.create();

        // Initialize DigestScheme without setting any `nextNonce`
        final DigestScheme authscheme = new DigestScheme();
        final String challenge = StandardAuthScheme.DIGEST + " realm=\"realm1\", nonce=\"initialNonce\"";
        final AuthChallenge authChallenge = parse(challenge);
        authscheme.processChallenge(authChallenge, context);

        // Simulate credentials validation and generate auth response
        authscheme.isResponseReady(host, credentialsProvider, context);
        final String authResponse = authscheme.generateAuthResponse(host, request, context);

        // Validate that the nonce in the response matches the initial nonce, not a nextNonce
        final Map<String, String> paramMap = parseAuthResponse(authResponse);
        Assertions.assertEquals("initialNonce", paramMap.get("nonce"), "The nonce should match the initial nonce provided in the challenge.");

        // Verify that the context does not contain any `nextNonce` value set
        Assertions.assertNull(context.getAttribute("auth-nextnonce"), "The context should not contain a nextNonce attribute.");
    }
Test digest authentication with unknown qop value
httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java