fix: accept external Workdirs in Browser subscriptions
This commit is contained in:
@@ -214,6 +214,8 @@ fn rust_serialized_subscription_frame_fixtures() -> Vec<SubscriptionFrame> {
|
|||||||
SubscriptionId::new("fixture-subscription").expect("fixture subscription id must be valid");
|
SubscriptionId::new("fixture-subscription").expect("fixture subscription id must be valid");
|
||||||
let worker_id =
|
let worker_id =
|
||||||
SubscriptionWorkerId::new("fixture-worker").expect("fixture worker id must be valid");
|
SubscriptionWorkerId::new("fixture-worker").expect("fixture worker id must be valid");
|
||||||
|
let external_workdir_id = SubscriptionWorkdirId::new("fixture-external-workdir")
|
||||||
|
.expect("fixture external Workdir id must be valid");
|
||||||
let worker = SubscriptionWorker {
|
let worker = SubscriptionWorker {
|
||||||
worker_id: worker_id.clone(),
|
worker_id: worker_id.clone(),
|
||||||
runtime_id: Some("fixture-runtime".to_string()),
|
runtime_id: Some("fixture-runtime".to_string()),
|
||||||
@@ -226,7 +228,12 @@ fn rust_serialized_subscription_frame_fixtures() -> Vec<SubscriptionFrame> {
|
|||||||
workspace_id: Some("fixture-workspace".to_string()),
|
workspace_id: Some("fixture-workspace".to_string()),
|
||||||
display_name: None,
|
display_name: None,
|
||||||
profile: None,
|
profile: None,
|
||||||
workdir_attachments: Vec::new(),
|
workdir_attachments: vec![SubscriptionWorkerWorkdirAttachment {
|
||||||
|
alias: "external".to_string(),
|
||||||
|
repository_id: None,
|
||||||
|
repository_key: None,
|
||||||
|
working_directory_id: external_workdir_id,
|
||||||
|
}],
|
||||||
};
|
};
|
||||||
let subscribed = SubscriptionFrame::new(SubscriptionFramePayload::Response(
|
let subscribed = SubscriptionFrame::new(SubscriptionFramePayload::Response(
|
||||||
SubscriptionResponse::Subscribed {
|
SubscriptionResponse::Subscribed {
|
||||||
|
|||||||
@@ -391,8 +391,7 @@ function validateWorker(worker: SubscriptionWorker): boolean {
|
|||||||
if (
|
if (
|
||||||
!validateIdentifier(attachment.alias, MAX_RESOURCE_ID_BYTES) ||
|
!validateIdentifier(attachment.alias, MAX_RESOURCE_ID_BYTES) ||
|
||||||
!validateIdentifier(attachment.working_directory_id, MAX_RESOURCE_ID_BYTES) ||
|
!validateIdentifier(attachment.working_directory_id, MAX_RESOURCE_ID_BYTES) ||
|
||||||
attachment.repository_key == null ||
|
(attachment.repository_key != null && !validateRepositoryKey(attachment.repository_key)) ||
|
||||||
!validateRepositoryKey(attachment.repository_key) ||
|
|
||||||
aliases.has(attachment.alias) ||
|
aliases.has(attachment.alias) ||
|
||||||
workdirIds.has(attachment.working_directory_id)
|
workdirIds.has(attachment.working_directory_id)
|
||||||
) {
|
) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -42,6 +42,37 @@ Deno.test('generated subscription validator accepts a current exact frame', () =
|
|||||||
assert(result.value.frame === 'response', 'expected response frame');
|
assert(result.value.frame === 'response', 'expected response frame');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test('generated subscription validator accepts an external Workdir Worker', () => {
|
||||||
|
const result = decode(subscribedFrame({
|
||||||
|
snapshot: {
|
||||||
|
topic: 'workers',
|
||||||
|
data: {
|
||||||
|
workers: [
|
||||||
|
{
|
||||||
|
worker_id: 'worker-1',
|
||||||
|
runtime_id: 'runtime-1',
|
||||||
|
resource_key: 'worker-resource-1',
|
||||||
|
availability: 'observed',
|
||||||
|
subject_revision: 1,
|
||||||
|
state: 'idle',
|
||||||
|
has_running_internal_workers: false,
|
||||||
|
workspace_id: 'workspace-1',
|
||||||
|
display_name: 'Companion',
|
||||||
|
profile: 'companion',
|
||||||
|
workdir_attachments: [
|
||||||
|
{
|
||||||
|
alias: 'workspace',
|
||||||
|
working_directory_id: 'external-workdir-1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
assert(result.ok, `external Workdir Worker was rejected: ${JSON.stringify(result)}`);
|
||||||
|
});
|
||||||
|
|
||||||
Deno.test('Rust-serialized compatibility fixtures satisfy the generated Browser contract', () => {
|
Deno.test('Rust-serialized compatibility fixtures satisfy the generated Browser contract', () => {
|
||||||
for (const fixture of RUST_SERIALIZED_SUBSCRIPTION_FRAME_FIXTURES) {
|
for (const fixture of RUST_SERIALIZED_SUBSCRIPTION_FRAME_FIXTURES) {
|
||||||
const result = decode(fixture);
|
const result = decode(fixture);
|
||||||
|
|||||||
Reference in New Issue
Block a user