fix: sync canonical kiro.rs settings for upload
This commit is contained in:
@@ -64,3 +64,101 @@ test('kiro publisher builds kiro.rs payload from desktop auth runtime without pr
|
||||
assert.match(machineId, /^[0-9a-f]{64}$/);
|
||||
assert.equal(Object.prototype.hasOwnProperty.call(payload, 'profileArn'), false);
|
||||
});
|
||||
|
||||
test('kiro publisher reads latest kiro.rs key from background state instead of stale node snapshot', async () => {
|
||||
const api = loadPublisherApi();
|
||||
const requests = [];
|
||||
let liveState = {
|
||||
kiroTargetId: 'kiro-rs',
|
||||
kiroRsUrl: 'https://kiro.example.com/admin',
|
||||
kiroRsKey: 'live-key',
|
||||
email: 'aws-user@example.com',
|
||||
kiroRuntime: {
|
||||
register: {
|
||||
email: 'aws-user@example.com',
|
||||
},
|
||||
desktopAuth: {
|
||||
region: 'us-east-1',
|
||||
clientId: 'client-001',
|
||||
clientSecret: 'secret-001',
|
||||
refreshToken: 'refresh-token-001',
|
||||
},
|
||||
upload: {
|
||||
targetId: 'kiro-rs',
|
||||
},
|
||||
},
|
||||
settingsState: {
|
||||
flows: {
|
||||
kiro: {
|
||||
targetId: 'kiro-rs',
|
||||
targets: {
|
||||
'kiro-rs': {
|
||||
baseUrl: 'https://kiro.example.com/admin',
|
||||
apiKey: 'live-key',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const completed = [];
|
||||
const publisher = api.createKiroRsPublisher({
|
||||
addLog: async () => {},
|
||||
completeNodeFromBackground: async (nodeId, payload) => {
|
||||
completed.push({ nodeId, payload });
|
||||
},
|
||||
fetchImpl: async (url, options = {}) => {
|
||||
requests.push({
|
||||
url,
|
||||
method: options.method || 'GET',
|
||||
apiKey: options.headers?.['x-api-key'],
|
||||
});
|
||||
if ((options.method || 'GET') === 'GET') {
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
text: async () => JSON.stringify({ items: [] }),
|
||||
};
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
text: async () => JSON.stringify({
|
||||
message: 'Credential uploaded.',
|
||||
credentialId: 9,
|
||||
email: 'aws-user@example.com',
|
||||
}),
|
||||
};
|
||||
},
|
||||
getState: async () => ({ ...liveState }),
|
||||
setState: async (updates = {}) => {
|
||||
liveState = { ...liveState, ...updates };
|
||||
},
|
||||
});
|
||||
|
||||
await publisher.executeKiroUploadCredential({
|
||||
nodeId: 'kiro-upload-credential',
|
||||
kiroRsKey: '',
|
||||
settingsState: {
|
||||
flows: {
|
||||
kiro: {
|
||||
targetId: 'kiro-rs',
|
||||
targets: {
|
||||
'kiro-rs': {
|
||||
baseUrl: 'https://kiro.example.com/admin',
|
||||
apiKey: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(requests.length, 2);
|
||||
assert.equal(requests[0].apiKey, 'live-key');
|
||||
assert.equal(requests[1].apiKey, 'live-key');
|
||||
assert.equal(completed.length, 1);
|
||||
assert.equal(completed[0].nodeId, 'kiro-upload-credential');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user