diff --git a/README.md b/README.md index de8676f..ffa6118 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ This integration test requires zerotier-one to be running. It may change configu AUTH_TOKEN=$(cat /path/to/authtoken.secret) npm test ``` +If you have a pre-release version of zerotier-one try: + +``` sh +ENABLE_UNSTABLE=1 npm t +``` + ## missing features Features not implemented by typespec yet @@ -44,10 +50,9 @@ When main is in a state you'd like to create a new release for: - create a feature branch off `main` - `npm version major|minor|patch` This bumps the version and updates the changelog -- `npm run build` - This is a little chicken and eggy. The build script updates the the spec version based on the npm package version, which just got updated above. - commit && push - create PR +- when the action finishes, you can check the output artifacts index.html - get merged to `main` ### On Github, create release: diff --git a/main.tsp b/main.tsp index 4d8119c..c77eec3 100644 --- a/main.tsp +++ b/main.tsp @@ -356,7 +356,7 @@ model ControllerNetworkMeta { @jsonSchema model ControllerNetworks { - data: ControllerNetworkMeta[]; + data: ControllerNetwork[]; meta: { networkCount: uSafeint; }; @@ -395,7 +395,7 @@ model ControllerNetworkProps { @jsonSchema model ControllerNetworkMember { @key id: ZTAddress; - ...ControllerNetworkMemberProps; + ...OptionalProperties; address: ZTAddress; authenticationExpiryTime: uSafeint; capabilities: uSafeint[]; @@ -426,6 +426,7 @@ model ControllerNetworkMemberProps { authorized: boolean; activeBridge: boolean; ipAssignments: IP[]; + name: string; noAutoAssignIps: boolean; ssoExempt: boolean; } diff --git a/test/integration_test.ts b/test/integration_test.ts index c7d3a03..57b5676 100644 --- a/test/integration_test.ts +++ b/test/integration_test.ts @@ -15,6 +15,8 @@ if (!process.env.AUTH_TOKEN) { process.exit(1); } +const isNextApiVersion = process.env.ENABLE_UNSTABLE; + function createCreateClient() { // AUTH_TOKEN=`cat ~/Library/Application\ Support/ZeroTier/One/authtoken.secret ` npm t const authToken = process.env.AUTH_TOKEN; @@ -118,7 +120,7 @@ describe("API exercise", async function () { assert.ok(data.includes(network_id)); }); - it("Creates a controller network member", async () => { + it("Creates a controller network member", async () => { const { data } = await client.POST( "/controller/network/{network_id}/member/{node_id}", { @@ -163,15 +165,6 @@ describe("API exercise", async function () { assertValid(validator, data); }); - it("Deletes the network by ID", async () => { - const { data: networkData3 } = await client.DELETE( - "/controller/network/{network_id}", - { params: { path: { network_id } } }, - ); - const networkDelValidator = createValidator("ControllerNetwork"); - assertValid(networkDelValidator, networkData3); - }); - describe("Joining networks", async () => { const network_id = "ff00160016000000"; @@ -218,23 +211,36 @@ describe("API exercise", async function () { assertValid(validator, data); }); }); - /// unstable - it("Lists full networks", async () => { - const { data, response } = await client.GET("/unstable/controller/network"); - if (response.status !== 404) { + + describe("Unstable APIs", { skip: !isNextApiVersion }, async () => { + it("Sets the member name", async () => { + const { data } = await client.POST( + "/controller/network/{network_id}/member/{node_id}", + { + params: { path: { network_id, node_id } }, + body: { authorized: true, name: "bob" }, + }, + ); + assert(data); + + const validator = createValidator("ControllerNetworkMember"); + assertValid(validator, data); + }); + + it("Lists full networks", async () => { + const { data } = await client.GET("/unstable/controller/network"); assert(data); const networksValidator = createValidator("ControllerNetworks"); assertValid(networksValidator, data); - } - }); + }); - it("Lists full network members", async () => { - const { data, response } = await client.GET( - "/unstable/controller/network/{network_id}/member", - ); - if (response.status !== 404) { + it("Lists full network members", async () => { + const { data } = await client.GET( + "/unstable/controller/network/{network_id}/member", + { params: { path: { network_id } } }, + ); assert(data); const networksValidator = createValidator( @@ -242,6 +248,29 @@ describe("API exercise", async function () { ); assertValid(networksValidator, data); - } + }); + + it("Gets the member name", async () => { + const { data } = await client.GET( + "/controller/network/{network_id}/member/{node_id}", + { + params: { path: { network_id, node_id } }, + }, + ); + assert(data); + assert.equal("bob", data.name); + + const validator = createValidator("ControllerNetworkMember"); + assertValid(validator, data); + }); }); + + // it("Deletes the network by ID", async () => { + // const { data } = await client.DELETE( + // "/controller/network/{network_id}", + // { params: { path: { network_id } } }, + // ); + // const networkDelValidator = createValidator("ControllerNetwork"); + // assertValid(networkDelValidator, data); + // }); });