<commit_before>#include <cstdlib>
#include "pkcs11test.h"

using namespace std;  // So sue me

TEST_F(ReadOnlySessionTest, EnumerateObjects) {
  EXPECT_CKR_OK(g_fns->C_FindObjectsInit(session_, NULL_PTR, 0));
  while (true) {
    CK_OBJECT_HANDLE object;
    CK_ULONG object_count;
    EXPECT_CKR_OK(g_fns->C_FindObjects(session_, &object, 1, &object_count));
    if (object_count == 0) break;
    CK_ULONG object_size;
    EXPECT_CKR_OK(g_fns->C_GetObjectSize(session_, object, &object_size));
    cout << "  object x" << setw(8) << setfill('0') << hex << (unsigned int)object << " (size=" << (int)object_size << ")" << endl;

    for (int ii = 0; ii < pkcs11_attribute_count; ii++) {
      CK_BYTE buffer[2048];
      CK_ATTRIBUTE attr;
      attr.type = pkcs11_attribute_info[ii].val;
      attr.pValue = &(buffer[0]);
      attr.ulValueLen = sizeof(buffer);
      CK_RV rv = g_fns->C_GetAttributeValue(session_, object, &attr, 1);
      if (rv == CKR_OK) {
        cout << "    " << attribute_description(&attr) << endl;
      }
    }
  }
  EXPECT_CKR_OK(g_fns->C_FindObjectsFinal(session_));
}
<commit_msg>Enumerate objects logged in too<commit_after>#include <cstdlib>
#include "pkcs11test.h"

using namespace std;  // So sue me

namespace {
void EnumerateObjects(CK_SESSION_HANDLE session) {
  EXPECT_CKR_OK(g_fns->C_FindObjectsInit(session, NULL_PTR, 0));
  while (true) {
    CK_OBJECT_HANDLE object;
    CK_ULONG object_count;
    EXPECT_CKR_OK(g_fns->C_FindObjects(session, &object, 1, &object_count));
    if (object_count == 0) break;
    CK_ULONG object_size;
    EXPECT_CKR_OK(g_fns->C_GetObjectSize(session, object, &object_size));
    cout << "  object x" << setw(8) << setfill('0') << hex << (unsigned int)object << " (size=" << (int)object_size << ")" << endl;

    for (int ii = 0; ii < pkcs11_attribute_count; ii++) {
      CK_BYTE buffer[2048];
      CK_ATTRIBUTE attr;
      attr.type = pkcs11_attribute_info[ii].val;
      attr.pValue = &(buffer[0]);
      attr.ulValueLen = sizeof(buffer);
      CK_RV rv = g_fns->C_GetAttributeValue(session, object, &attr, 1);
      if (rv == CKR_OK) {
        cout << "    " << attribute_description(&attr) << endl;
      }
    }
  }
  EXPECT_CKR_OK(g_fns->C_FindObjectsFinal(session));
}

}  // namespace

TEST_F(ReadOnlySessionTest, EnumerateObjects) {
  EnumerateObjects(session_);
}

TEST_F(ROUserSessionTest, EnumerateObjects) {
  EnumerateObjects(session_);
}


{'fraction_non_alphanumeric': 0.1453871499176277, 'fraction_numerical': 0.014827018121911038, 'mean_word_length': 3.9571428571428573, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 15, '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': '4058286', 'n_tokens_mistral': 922, 'n_tokens_neox': 897, 'n_words': 163}