Fix member list api, improve tests

This commit is contained in:
travisladuke
2024-02-29 08:12:58 -08:00
committed by Travis LaDuke
parent f11f98e562
commit 99e78f3a64
3 changed files with 61 additions and 26 deletions
+7 -2
View File
@@ -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:
+3 -2
View File
@@ -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<ControllerNetworkMemberProps>;
address: ZTAddress;
authenticationExpiryTime: uSafeint;
capabilities: uSafeint[];
@@ -426,6 +426,7 @@ model ControllerNetworkMemberProps {
authorized: boolean;
activeBridge: boolean;
ipAssignments: IP[];
name: string;
noAutoAssignIps: boolean;
ssoExempt: boolean;
}
+51 -22
View File
@@ -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);
// });
});