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
2 changes: 2 additions & 0 deletions src/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export const WEB_CLI_ANONYMOUS_RESTRICTED_COMMANDS = [
// Integrations and queues are not available to anonymous users
"integrations*",
"queues*",

"push*", // push commands not available to anonymous users
];

/* Commands not suitable for interactive mode */
Expand Down
1 change: 0 additions & 1 deletion src/commands/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default class AppsCommand extends BaseTopicCommand {
"$ ably apps create",
"$ ably apps update",
"$ ably apps delete",
"$ ably apps set-apns-p12",
"$ ably apps stats",
"$ ably apps channel-rules list",
"$ ably apps switch my-app",
Expand Down
12 changes: 12 additions & 0 deletions src/commands/push/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BaseTopicCommand } from "../../base-topic-command.js";

export default class PushIndexCommand extends BaseTopicCommand {
protected topicName = "push";
protected commandGroup = "push notifications";

static description = "Manage Ably Push Notifications";

static examples = [
"<%= config.bin %> <%= command.id %> set-apns-p12 APP_ID --certificate /path/to/cert.p12",
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from "node:path";

import { ControlBaseCommand } from "../../control-base-command.js";

export default class AppsSetApnsP12Command extends ControlBaseCommand {
export default class PushSetApnsP12Command extends ControlBaseCommand {
static args = {
id: Args.string({
description: "App ID to set the APNS certificate for",
Expand All @@ -16,9 +16,9 @@ export default class AppsSetApnsP12Command extends ControlBaseCommand {
"Upload Apple Push Notification Service P12 certificate for an app";

static examples = [
"$ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12",
'$ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12 --password "YOUR_CERTIFICATE_PASSWORD"',
"$ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12 --use-for-sandbox",
"$ ably push set-apns-p12 app-id --certificate /path/to/certificate.p12",
'$ ably push set-apns-p12 app-id --certificate /path/to/certificate.p12 --password "YOUR_CERTIFICATE_PASSWORD"',
"$ ably push set-apns-p12 app-id --certificate /path/to/certificate.p12 --use-for-sandbox",
];

static flags = {
Expand All @@ -38,7 +38,7 @@ export default class AppsSetApnsP12Command extends ControlBaseCommand {
};

async run(): Promise<void> {
const { args, flags } = await this.parse(AppsSetApnsP12Command);
const { args, flags } = await this.parse(PushSetApnsP12Command);

// Display authentication information
this.showAuthInfoIfNeeded(flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mkdirSync, writeFileSync, existsSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { getMockConfigManager } from "../../../helpers/mock-config-manager.js";

describe("apps:set-apns-p12 command", () => {
describe("push:set-apns-p12 command", () => {
let testTempDir: string;
let testCertFile: string;

Expand Down Expand Up @@ -39,7 +39,7 @@ describe("apps:set-apns-p12 command", () => {
});

const { stdout } = await runCommand(
["apps:set-apns-p12", appId, "--certificate", testCertFile],
["push:set-apns-p12", appId, "--certificate", testCertFile],
import.meta.url,
);

Expand All @@ -57,7 +57,7 @@ describe("apps:set-apns-p12 command", () => {

const { stdout } = await runCommand(
[
"apps:set-apns-p12",
"push:set-apns-p12",
appId,
"--certificate",
testCertFile,
Expand All @@ -81,7 +81,7 @@ describe("apps:set-apns-p12 command", () => {

const { stdout } = await runCommand(
[
"apps:set-apns-p12",
"push:set-apns-p12",
appId,
"--certificate",
testCertFile,
Expand All @@ -98,7 +98,7 @@ describe("apps:set-apns-p12 command", () => {
describe("error handling", () => {
it("should require app ID argument", async () => {
const { error } = await runCommand(
["apps:set-apns-p12", "--certificate", testCertFile],
["push:set-apns-p12", "--certificate", testCertFile],
import.meta.url,
);

Expand All @@ -109,7 +109,7 @@ describe("apps:set-apns-p12 command", () => {
it("should require certificate flag", async () => {
const appId = getMockConfigManager().getCurrentAppId()!;
const { error } = await runCommand(
["apps:set-apns-p12", appId],
["push:set-apns-p12", appId],
import.meta.url,
);

Expand All @@ -121,7 +121,7 @@ describe("apps:set-apns-p12 command", () => {
const appId = getMockConfigManager().getCurrentAppId()!;
const { error } = await runCommand(
[
"apps:set-apns-p12",
"push:set-apns-p12",
appId,
"--certificate",
"/nonexistent/path/cert.p12",
Expand All @@ -140,7 +140,7 @@ describe("apps:set-apns-p12 command", () => {
.reply(400, { error: "Invalid certificate" });

const { error } = await runCommand(
["apps:set-apns-p12", appId, "--certificate", testCertFile],
["push:set-apns-p12", appId, "--certificate", testCertFile],
import.meta.url,
);

Expand All @@ -155,7 +155,7 @@ describe("apps:set-apns-p12 command", () => {
.reply(401, { error: "Unauthorized" });

const { error } = await runCommand(
["apps:set-apns-p12", appId, "--certificate", testCertFile],
["push:set-apns-p12", appId, "--certificate", testCertFile],
import.meta.url,
);

Expand Down
Loading