<commit_before>package org.ccnx.ccn.test.profiles.access;

import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.Assert;

import java.util.Random;
import java.util.ArrayList;

import org.ccnx.ccn.CCNHandle;
import org.ccnx.ccn.config.UserConfiguration;
import org.ccnx.ccn.io.RepositoryOutputStream;
import org.ccnx.ccn.io.content.Link;
import org.ccnx.ccn.protocol.ContentName;
import org.ccnx.ccn.profiles.access.AccessControlManager;
import org.ccnx.ccn.profiles.access.ACL;
import org.ccnx.ccn.profiles.access.ACL.ACLObject;
import org.ccnx.ccn.test.profiles.access.TestUserData;

/**
 * This test relies on org.ccn.ccn.test.profiles.access.TestUserData to generate users
 * for the access control test.
 *
 */

public class AccessControlManagerTestRepo {

	static AccessControlManager acm;
	static ContentName baseNode, childNode, grandchildNode;
	static ContentName userKeyStorePrefix, userNamespace;
	static int userCount = 3;
	static TestUserData td;
	static String[] friendlyNames;
	static Link lk, lk2;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		// create base node, child node and grandchild node
		Random rand = new Random();
		String directoryBase = "/test/AccessControlManagerTestRepo-";
		baseNode = ContentName.fromNative(directoryBase + Integer.toString(rand.nextInt(10000)));
		childNode = ContentName.fromNative(baseNode, "child");
		grandchildNode = ContentName.fromNative(childNode, "grandchild");
		
		// write some content in grandchild node
//		RepositoryOutputStream ros = new RepositoryOutputStream(grandchildNode, CCNHandle.open());
//		ros.setTimeout(5000);
//		byte [] data = "Grandchild content".getBytes();
//		ros.write(data, 0, data.length);
//		ros.close();
		
		// create user identities with TestUserData
		ContentName testPrefix = UserConfiguration.defaultNamespace();
		userKeyStorePrefix = ContentName.fromNative(testPrefix, "_access_");
		userNamespace = ContentName.fromNative(testPrefix, "home");
		td = new TestUserData(userKeyStorePrefix, userCount, true, "password".toCharArray(), CCNHandle.open());
		td.saveUserPK2Repo(userNamespace);
		friendlyNames = td.friendlyNames().toArray(new String[0]);
		Assert.assertEquals(userCount, friendlyNames.length);
	}
	
	/**<commit_msg>Deleted commented out portion of code in AccessControlManagerTestRepo<commit_after>package org.ccnx.ccn.test.profiles.access;

import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.Assert;

import java.util.Random;
import java.util.ArrayList;

import org.ccnx.ccn.CCNHandle;
import org.ccnx.ccn.config.UserConfiguration;
import org.ccnx.ccn.io.content.Link;
import org.ccnx.ccn.protocol.ContentName;
import org.ccnx.ccn.profiles.access.AccessControlManager;
import org.ccnx.ccn.profiles.access.ACL;
import org.ccnx.ccn.profiles.access.ACL.ACLObject;
import org.ccnx.ccn.test.profiles.access.TestUserData;

/**
 * This test relies on org.ccn.ccn.test.profiles.access.TestUserData to generate users
 * for the access control test.
 *
 */

public class AccessControlManagerTestRepo {

	static AccessControlManager acm;
	static ContentName baseNode, childNode, grandchildNode;
	static ContentName userKeyStorePrefix, userNamespace;
	static int userCount = 3;
	static TestUserData td;
	static String[] friendlyNames;
	static Link lk, lk2;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		// create base node, child node and grandchild node
		Random rand = new Random();
		String directoryBase = "/test/AccessControlManagerTestRepo-";
		baseNode = ContentName.fromNative(directoryBase + Integer.toString(rand.nextInt(10000)));
		childNode = ContentName.fromNative(baseNode, "child");
		grandchildNode = ContentName.fromNative(childNode, "grandchild");
				
		// create user identities with TestUserData
		ContentName testPrefix = UserConfiguration.defaultNamespace();
		userKeyStorePrefix = ContentName.fromNative(testPrefix, "_access_");
		userNamespace = ContentName.fromNative(testPrefix, "home");
		td = new TestUserData(userKeyStorePrefix, userCount, true, "password".toCharArray(), CCNHandle.open());
		td.saveUserPK2Repo(userNamespace);
		friendlyNames = td.friendlyNames().toArray(new String[0]);
		Assert.assertEquals(userCount, friendlyNames.length);
	}
	
	/**
{'fraction_non_alphanumeric': 0.10890858208955224, 'fraction_numerical': 0.005363805970149254, 'mean_word_length': 5.548091603053435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3112873', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1306, 'n_words': 285}