<commit_before>/*
 * Copyright (c) 2016-2018 Contributors to the Eclipse Foundation
 *
 *  See the NOTICE file(s) distributed with this work for additional
 *  information regarding copyright ownership.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package jwks;

import java.net.URL;

import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * Tests of the jwks and pemjwks URL protocol handlers
 */
public class JWKSResTest {
    /**
     * Install the custom protocol handlers using the java.protocol.handler.pkgs system property
     */
    @BeforeClass
    public static void installURLHandler() {
        // If other handlers are registered, don't overwrite them...
        String oldPkgs = System.getProperty("java.protocol.handler.pkgs", "");
        String newPkgs = "url";
        if(!oldPkgs.isEmpty()) {
            newPkgs += "|" + oldPkgs;
        }
        // Update handler packages
        System.out.printf("Updating java.protocol.handler.pkgs to: %s\n", newPkgs);
        System.setProperty("java.protocol.handler.pkgs", newPkgs);
    }

    /**
     *
     * @throws Exception
     */
    @Test
    public void testJwksURL() throws Exception {
        URL signerJwk = new URL("jwks:/signer.jwk");
        String signerJwkContent = signerJwk.getContent().toString();
        System.out.println(signerJwkContent);
        Assert.assertTrue(signerJwkContent.length() > 450, "Expect more than 450 chars in signer.jwk");
    }
    @Test
    public void testPemJwksURL() throws Exception {
        URL signerJwk = new URL("pemjwks:/publicKey.pem?kid=pem-test");
        String signerJwkContent = signerJwk.getContent().toString();
        System.out.println(signerJwkContent);
        Assert.assertTrue(signerJwkContent.length() > 400, "Expect more than 450 chars in publicKey.pem jwks");
    }
}<commit_msg>Use the signer-keyset.jwk rather than the signer.jwk.<commit_after>/*
 * Copyright (c) 2016-2018 Contributors to the Eclipse Foundation
 *
 *  See the NOTICE file(s) distributed with this work for additional
 *  information regarding copyright ownership.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package jwks;

import java.net.URL;

import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * Tests of the jwks and pemjwks URL protocol handlers
 */
public class JWKSResTest {
    /**
     * Install the custom protocol handlers using the java.protocol.handler.pkgs system property
     */
    @BeforeClass
    public static void installURLHandler() {
        // If other handlers are registered, don't overwrite them...
        String oldPkgs = System.getProperty("java.protocol.handler.pkgs", "");
        String newPkgs = "url";
        if(!oldPkgs.isEmpty()) {
            newPkgs += "|" + oldPkgs;
        }
        // Update handler packages
        System.out.printf("Updating java.protocol.handler.pkgs to: %s\n", newPkgs);
        System.setProperty("java.protocol.handler.pkgs", newPkgs);
    }

    /**
     *
     * @throws Exception
     */
    @Test
    public void testJwksURL() throws Exception {
        URL signerJwk = new URL("jwks:/signer-keyset.jwk");
        String signerJwkContent = signerJwk.getContent().toString();
        System.out.println(signerJwkContent);
        Assert.assertTrue(signerJwkContent.length() > 450, "Expect more than 450 chars in signer.jwk");
    }
    @Test
    public void testPemJwksURL() throws Exception {
        URL signerJwk = new URL("pemjwks:/publicKey.pem?kid=pem-test");
        String signerJwkContent = signerJwk.getContent().toString();
        System.out.println(signerJwkContent);
        Assert.assertTrue(signerJwkContent.length() > 400, "Expect more than 450 chars in publicKey.pem jwks");
    }
}
{'fraction_non_alphanumeric': 0.1022093743547388, 'fraction_numerical': 0.009911212058641337, 'mean_word_length': 3.1120543293718166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2968811', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1399, 'n_words': 434}