Skip to content
Open
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
1 change: 1 addition & 0 deletions api/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ type Vars implements Node {
flashProduct: String
flashVendor: String
tpmGuid: String
usbGuid: String
regCheck: String
regFile: String
regGuid: String
Expand Down
1 change: 1 addition & 0 deletions api/src/core/types/states/var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type Var = {
flashProduct: string;
flashVendor: string;
tpmGuid?: string;
usbGuid?: string;
/** Current progress of the {@link ?content=mover | mover}. */
fsCopyPrcnt: number;
fsNumMounted: number;
Expand Down
4 changes: 3 additions & 1 deletion api/src/store/services/__test__/state-file-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const VAR_FIXTURE = readFileSync(new URL('../../../../dev/states/var.ini', impor
const writeVarFixture = (dir: string, safeMode: 'yes' | 'no') => {
const content = VAR_FIXTURE.replace(/safeMode="(yes|no)"/, `safeMode="${safeMode}"`).replace(
/flashGUID="([^"]+)"/,
'flashGUID="$1"\ntpmGUID="01-V35H8S0L1QHK1SBG1XHXJNH7"'
'flashGUID="$1"\ntpmGUID="01-V35H8S0L1QHK1SBG1XHXJNH7"\nusbGUID="058F-6387-0000-0000F1F1E1C6"'
);
writeFileSync(join(dir, `${StateFileKey.var}.ini`), content);
};
Expand Down Expand Up @@ -47,6 +47,7 @@ describe('loadStateFileSync', () => {

expect(result?.safeMode).toBe(true);
expect(result?.tpmGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(result?.usbGuid).toBe('058F-6387-0000-0000F1F1E1C6');
expect(dispatchSpy).toHaveBeenCalledWith(
expect.objectContaining({
type: 'emhttp/updateEmhttpState',
Expand All @@ -55,6 +56,7 @@ describe('loadStateFileSync', () => {
state: expect.objectContaining({
safeMode: true,
tpmGuid: '01-V35H8S0L1QHK1SBG1XHXJNH7',
usbGuid: '058F-6387-0000-0000F1F1E1C6',
}),
},
})
Expand Down
1 change: 1 addition & 0 deletions api/src/store/state-parsers/var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type VarIni = {
flashProduct: string;
flashVendor: string;
tpmGuid?: string;
usbGuid?: string;
fsCopyPrcnt: string;
fsNumMounted: string;
fsNumUnmountable: string;
Expand Down
1 change: 1 addition & 0 deletions api/src/unraid-api/cli/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,7 @@ export type Vars = Node & {
sysModel?: Maybe<Scalars['String']['output']>;
timeZone?: Maybe<Scalars['String']['output']>;
tpmGuid?: Maybe<Scalars['String']['output']>;
usbGuid?: Maybe<Scalars['String']['output']>;
/** Should a NTP server be used for time sync? */
useNtp?: Maybe<Scalars['Boolean']['output']>;
useSsh?: Maybe<Scalars['Boolean']['output']>;
Expand Down
3 changes: 3 additions & 0 deletions api/src/unraid-api/graph/resolvers/vars/vars.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ export class Vars extends Node {
@Field({ nullable: true })
tpmGuid?: string;

@Field({ nullable: true })
usbGuid?: string;

@Field({ nullable: true })
regCheck?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ public function getServerState()
"flashProduct" => $this->var['flashProduct'],
"flashVendor" => $this->var['flashVendor'],
"flashBackupActivated" => $this->flashBackupActivated,
"flashGuid" => $this->var['flashGUID'] ?? '',
"guid" => $this->var['flashGUID'],
"tpmGuid" => $this->var['tpmGUID'] ?? '',
"usbGuid" => $this->var['usbGUID'] ?? '',
"hasRemoteApikey" => $this->hasRemoteApikey,
"internalPort" => _var($_SERVER, 'SERVER_PORT'),
"keyfile" => $this->keyfileBase64UrlSafe,
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions web/__test__/components/Registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const initialServerState = {
dateTimeFormat: { date: 'MMM D, YYYY', time: 'h:mm A' },
deviceCount: 0,
flashGuid: '',
usbGuid: '',
guid: '',
keyfile: '',
mdState: '',
Expand Down Expand Up @@ -342,6 +343,7 @@ describe('Registration.standalone.vue', () => {
serverStore.state = 'PRO';
serverStore.guid = '058F-6387-0000-0000F1F1E1C6';
serverStore.flashGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.usbGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.tpmGuid = '01-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.keyfile = 'keyfile-present';

Expand All @@ -351,9 +353,42 @@ describe('Registration.standalone.vue', () => {

expect(moveButton.exists()).toBe(true);
expect(moveButton.attributes('disabled')).toBeUndefined();
expect(findItemByLabel(t('registration.flashGuid'))?.props('text')).toBe(
'058F-6387-0000-0000F1F1E1C6'
);
expect(findItemByLabel(t('TPM GUID'))?.props('text')).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
});

it('shows both licensing GUIDs when no key is installed', async () => {
serverStore.state = 'ENOKEYFILE';
serverStore.guid = '058F-6387-0000-0000F1F1E1C6';
serverStore.flashGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.usbGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.tpmGuid = '01-V35H8S0L1QHK1SBG1XHXJNH7';

await wrapper.vm.$nextTick();

expect(findItemByLabel(t('registration.flashGuid'))?.props('text')).toBe(
'058F-6387-0000-0000F1F1E1C6'
);
expect(findItemByLabel(t('TPM GUID'))?.props('text')).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(wrapper.find('[data-testid="move-license-to-tpm"]').exists()).toBe(false);
});

it('does not label the selected TPM GUID as a USB GUID', async () => {
serverStore.guid = '01-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.flashGuid = '01-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.tpmGuid = '01-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.usbGuid = '';

await wrapper.vm.$nextTick();

expect(findItemByLabel(t('registration.flashGuid'))).toBeUndefined();
expect(findItemByLabel(t('registration.deviceGuid'))?.props('text')).toBe(
'01-V35H8S0L1QHK1SBG1XHXJNH7'
);
});

it('shows Move License to TPM when flashGuid is missing but the active GUID is still a flash GUID', async () => {
serverStore.state = 'PRO';
serverStore.guid = '058F-6387-0000-0000F1F1E1C6';
Expand Down
90 changes: 90 additions & 0 deletions web/__test__/store/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ const getStore = () => {
description: store.description,
deviceCount: store.deviceCount,
expireTime: store.expireTime,
flashGuid: store.flashGuid || undefined,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
usbGuid: store.usbGuid || undefined,
flashProduct: store.flashProduct,
flashVendor: store.flashVendor,
guid: store.guid,
Expand All @@ -203,6 +205,7 @@ const getStore = () => {
regTy: store.regTy,
regUpdatesExpired: store.regUpdatesExpired,
state: store.state,
tpmGuid: store.tpmGuid || undefined,
wanFQDN: store.wanFQDN,
};

Expand All @@ -218,6 +221,8 @@ const getStore = () => {
deviceCount: store.deviceCount,
description: store.description,
expireTime: store.expireTime,
flashGuid: store.flashGuid || undefined,
usbGuid: store.usbGuid || undefined,
flashProduct: store.flashProduct,
flashVendor: store.flashVendor,
guid: store.guid,
Expand All @@ -233,6 +238,7 @@ const getStore = () => {
regTy: store.regTy,
regUpdatesExpired: store.regUpdatesExpired,
state: store.state,
tpmGuid: store.tpmGuid || undefined,
wanFQDN: store.wanFQDN,
};

Expand Down Expand Up @@ -292,6 +298,14 @@ const getStore = () => {
return store;
};

const getActualStore = () =>
useServerStore(
createTestingPinia({
createSpy: vi.fn,
stubActions: false,
})
);

// Mock dependent stores
vi.mock('~/store/account', () => ({
useAccountStore: vi.fn(() => ({
Expand Down Expand Up @@ -651,6 +665,7 @@ describe('useServerStore', () => {
deviceCount: 6,
description: 'Test Server',
expireTime: 123,
flashGuid: 'flash-guid-1',
flashProduct: 'TestFlash',
flashVendor: 'TestVendor',
guid: '123456',
Expand All @@ -675,6 +690,7 @@ describe('useServerStore', () => {
expect(payload.description).toBe('Test Server');
expect(payload.deviceCount).toBe(6);
expect(payload.expireTime).toBe(123);
expect(payload.flashGuid).toBe('flash-guid-1');
expect(payload.flashProduct).toBe('TestFlash');
expect(payload.flashVendor).toBe('TestVendor');
expect(payload.guid).toBe('123456');
Expand Down Expand Up @@ -767,6 +783,8 @@ describe('useServerStore', () => {
regGuid: 'reg-guid-1',
regTy: 'Plus',
state: 'PLUS' as ServerState,
tpmGuid: '01-TPM-GUID-1',
usbGuid: 'usb-guid-1',
wanFQDN: 'test.myunraid.net',
});

Expand All @@ -777,6 +795,7 @@ describe('useServerStore', () => {
expect(payload.deviceCount).toBe(6);
expect(payload.description).toBe('Test Server');
expect(payload.expireTime).toBe(123);
expect(payload.flashGuid).toBe('flash-guid-1');
expect(payload.flashProduct).toBe('TestFlash');
expect(payload.flashVendor).toBe('TestVendor');
expect(payload.guid).toBe('123456');
Expand All @@ -792,9 +811,80 @@ describe('useServerStore', () => {
expect(payload.regTy).toBe('Plus');
expect(payload.regUpdatesExpired).toBe(true);
expect(payload.state).toBe('PLUS');
expect(payload.tpmGuid).toBe('01-TPM-GUID-1');
expect(payload.usbGuid).toBe('usb-guid-1');
expect(payload.wanFQDN).toBe('test.myunraid.net');
});

it('should include physical identities in the actual callback payloads', () => {
const store = getActualStore();

store.setServer({
flashGuid: '01-V35H8S0L1QHK1SBG1XHXJNH7',
guid: '01-V35H8S0L1QHK1SBG1XHXJNH7',
tpmGuid: '01-V35H8S0L1QHK1SBG1XHXJNH7',
usbGuid: '058F-6387-0000-0000F1F1E1C6',
} as Server);

expect(store.serverPurchasePayload.flashGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverPurchasePayload.guid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverPurchasePayload.tpmGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverPurchasePayload.usbGuid).toBe('058F-6387-0000-0000F1F1E1C6');
expect(store.serverAccountPayload.flashGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverAccountPayload.tpmGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverAccountPayload.usbGuid).toBe('058F-6387-0000-0000F1F1E1C6');
expect(store.serverReplacePayload.flashGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverReplacePayload.tpmGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(store.serverReplacePayload.usbGuid).toBe('058F-6387-0000-0000F1F1E1C6');
});

it('should preserve physical identities without inventing a selected GUID for an unregistered server', () => {
const store = getActualStore();

store.setServer({
flashGuid: '',
guid: '',
regGuid: '',
state: 'ENOKEYFILE',
tpmGuid: '01-V35H8S0L1QHK1SBG1XHXJNH7',
usbGuid: '058F-6387-0000-0000F1F1E1C6',
} as Server);

for (const payload of [
store.serverPurchasePayload,
store.serverAccountPayload,
store.serverReplacePayload,
]) {
expect(payload.flashGuid).toBeUndefined();
expect(payload.tpmGuid).toBe('01-V35H8S0L1QHK1SBG1XHXJNH7');
expect(payload.usbGuid).toBe('058F-6387-0000-0000F1F1E1C6');
}
expect(store.serverPurchasePayload.guid).toBe('');
expect(store.serverAccountPayload.guid).toBe('');
expect(store.serverReplacePayload.guid).toBeUndefined();
});

it('should keep the legacy selected GUID when physical identity fields are absent', () => {
const store = getActualStore();

store.setServer({
flashGuid: '058F-6387-0000-0000F1F1E1C6',
guid: '058F-6387-0000-0000F1F1E1C6',
state: 'PRO',
} as Server);

for (const payload of [
store.serverPurchasePayload,
store.serverAccountPayload,
store.serverReplacePayload,
]) {
expect(payload.flashGuid).toBe('058F-6387-0000-0000F1F1E1C6');
expect(payload.guid).toBe('058F-6387-0000-0000F1F1E1C6');
expect(payload.usbGuid).toBeUndefined();
expect(payload.tpmGuid).toBeUndefined();
}
});

it('should create serverReplacePayload with TPM guid when available on flash boot', () => {
const store = getStore();

Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"@nuxt/ui": "4.8.2",
"@tanstack/vue-table": "8.21.3",
"@tiptap/y-tiptap": "3.0.7",
"@unraid/shared-callbacks": "3.1.0",
"@unraid/shared-callbacks": "3.3.0",
"@unraid/ui": "link:../unraid-ui",
"@vue/apollo-composable": "4.2.2",
"@vueuse/components": "13.8.0",
Expand Down
32 changes: 24 additions & 8 deletions web/src/components/Registration.standalone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const {
hasDistinctTpmGuid,
dateTimeFormat,
deviceCount,
usbGuid,
flashProduct,
flashVendor,
guid,
Expand Down Expand Up @@ -133,25 +134,40 @@ const showTpmTransferButton = computed((): boolean =>
);
const disableTpmTransferButton = computed((): boolean => showTrialExpiration.value);

// Organize items into three sections
const bootDeviceItems = computed((): RegistrationItemProps[] => {
return [
...(guid.value
const licensingGuidItems = computed((): RegistrationItemProps[] => {
const items: RegistrationItemProps[] = [
...(usbGuid.value
? [
{
label: t('registration.deviceGuid'),
text: guid.value,
label: t('registration.flashGuid'),
text: usbGuid.value,
},
]
: []),
...(showTpmTransferButton.value && tpmGuid.value
: guid.value
? [
{
label: t('registration.deviceGuid'),
text: guid.value,
},
]
: []),
...(tpmGuid.value && (usbGuid.value || tpmGuid.value !== guid.value)
? [
{
label: t('registration.tpmGuid'),
text: tpmGuid.value,
},
]
: []),
];

return items;
});

// Organize items into three sections
const bootDeviceItems = computed((): RegistrationItemProps[] => {
return [
...licensingGuidItems.value,
...(bootDeviceType.value
? [
{
Expand Down
Loading
Loading