Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@
*/
import * as React from 'react';
import { render, screen } from 'wrappedTestingLibrary';
import userEvent from '@testing-library/user-event';
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin';

import { createLookupTableAdapter } from 'fixtures/lookupTables';
import { asMock } from 'helpers/mocking';
import useScopePermissions from 'hooks/useScopePermissions';
import type { GenericEntityType } from 'logic/lookup-tables/types';
import { ModalProvider } from 'components/lookup-tables/contexts/ModalContext';
import { LookupTableDataAdaptersActions } from 'stores/lookup-tables/LookupTableDataAdaptersStore';

import CSVFileAdapterSummary from './adapters/CSVFileAdapterSummary';
import DataAdapter from './DataAdapter';

jest.mock('hooks/useScopePermissions');
jest.mock('stores/lookup-tables/LookupTableDataAdaptersStore', () => ({
LookupTableDataAdaptersActions: {
lookup: jest.fn(),
},
}));

PluginStore.register(
new PluginManifest(
Expand Down Expand Up @@ -85,4 +92,37 @@ describe('DataAdapter', () => {

expect(screen.queryByRole('button', { name: /edit/i })).not.toBeInTheDocument();
});

// Regression: PR #23432 introduced json-with-bigint which deserializes large numbers as BigInt.
// DataAdapter used native JSON.stringify to render lookup results, which throws
// "TypeError: Do not know how to serialize a BigInt" for values like AD's accountExpires.
// Introduced by: 5cb51acdcceb660c2cc75fc8c0ad48a17b543334 (2026-03-19)
it('should render lookup results containing BigInt values without crashing', async () => {
const lookupResultWithBigInt = {
single_value: 'testuser',
multi_value: {
sAMAccountName: 'testuser',
accountExpires: BigInt('9223372036854775807'),
pwdLastSet: BigInt('134185088795495957'),
displayName: 'Test User',
},
has_error: false,
ttl: 1000,
};

asMock(LookupTableDataAdaptersActions.lookup).mockResolvedValue(lookupResultWithBigInt);

renderedDataAdapter('DEFAULT');

const keyInput = screen.getByLabelText(/key/i);
const lookupButton = screen.getByRole('button', { name: /look up/i });

await userEvent.type(keyInput, 'testuser');
await userEvent.click(lookupButton);

await screen.findByText(/lookup result/i);

expect(screen.getByText(/9223372036854775807/)).toBeInTheDocument();
expect(screen.getByText(/testuser/)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import * as React from 'react';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { JSONStringify } from 'json-with-bigint';

import Routes from 'routing/Routes';
import usePluginEntities from 'hooks/usePluginEntities';
Expand Down Expand Up @@ -114,7 +115,7 @@ const DataAdapter = ({ dataAdapter, noEdit = false }: Props) => {
{lookupResult && (
<div>
<h4>Lookup result</h4>
<pre>{JSON.stringify(lookupResult, null, 2)}</pre>
<pre>{JSONStringify(lookupResult, null, 2)}</pre>
</div>
)}
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import * as React from 'react';
import { useState, useMemo } from 'react';
import styled from 'styled-components';
import { JSONStringify } from 'json-with-bigint';

import useProductName from 'brand-customization/useProductName';
import { useErrorsContext } from 'components/lookup-tables/contexts/ErrorsContext';
Expand Down Expand Up @@ -68,7 +69,7 @@ function TestLookup({ table }: Props) {
const dataPreview = useMemo(() => {
if (total === 0) return 'No results to show';

return JSON.stringify(results, null, 2);
return JSONStringify(results, null, 2);
}, [results, total]);

const onChange = (event: React.BaseSyntheticEvent) => {
Expand All @@ -94,7 +95,7 @@ function TestLookup({ table }: Props) {

if (lookupKey.valid) {
testLookupTableKey({ tableName: table.name, key: lookupKey.value }).then((resp: any) => {
setLookupResult(JSON.stringify(resp, null, 2));
setLookupResult(JSONStringify(resp, null, 2));
setLookupKey({ value: '', valid: false });
});
}
Expand Down
Loading