Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@adobe/aio-lib-env": "^3",
"@adobe/aio-lib-ims": "^7",
"@oclif/core": "^4.0.0",
"hyperlinker": "^1.0.0",
"js-yaml": "^4.1.0",
"open": "^10.2.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/api/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ListCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const enabledServices = await this.consoleCLI.getEnabledServicesForOrg(orgId)
aioConsoleLogger.debug(`Enabled services: ${JSON.stringify(enabledServices.map(s => s.code))}`)

Expand Down
36 changes: 36 additions & 0 deletions src/commands/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ const LibConsoleCLI = require('@adobe/aio-cli-lib-console')
const { CLI } = require('@adobe/aio-lib-ims/src/context')
const { getCliEnv } = require('@adobe/aio-lib-env')
const yaml = require('js-yaml')
const hyperlinker = require('hyperlinker')
const { CONFIG_KEYS, API_KEYS } = require('../../config')

const DEV_TERMS_URL = 'https://www.adobe.com/go/developer-terms'

class ConsoleCommand extends Command {
async run () {
const help = new Help(this.config)
Expand Down Expand Up @@ -89,6 +92,39 @@ class ConsoleCommand extends Command {
LibConsoleCLI.cleanStdOut()
}

/**
* Ensure the Developer Terms of Service have been accepted for the given org.
* Mirrors the flow in @adobe/aio-cli-plugin-app's `app init` command so that
* `console` subcommands surface a CLI-native prompt instead of leaking a raw
* 451 "use POST /console/services/ims/organizations/:orgId/terms" message
* from the underlying SDK.
*
* @param {object} consoleCLI initialised @adobe/aio-cli-lib-console instance (this.consoleCLI)
* @param {string} orgId organization id to check
* @param {boolean} [skipPrompts] when true, fail fast instead of prompting (default false)
* @returns {Promise<void>}
*/
async ensureDevTermAccepted (consoleCLI, orgId, skipPrompts = false) {
const isTermAccepted = await consoleCLI.checkDevTermsForOrg(orgId)
if (isTermAccepted) {
return
}
if (skipPrompts) {
this.error('Developer Terms of Service have not been accepted for this organization. Please re-run this command without `--json`/`--yml`, or run `aio app init` to accept the terms first.')
}
const terms = await consoleCLI.getDevTermsForOrg()
const termsText = terms.text ? terms.text.trim() : ''
const confirmDevTerms = await consoleCLI.prompt.promptConfirm(`${termsText}\n\nYou have not accepted the Developer Terms of Service. Go to ${hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL)} to view the terms. Do you accept the terms? (y/n):`)
if (!confirmDevTerms) {
this.error('The Developer Terms of Service were declined')
}
const accepted = await consoleCLI.acceptDevTermsForOrg(orgId)
if (!accepted) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt string has a raw newline followed by \n and 4 spaces of indentation, which will render as an extra blank line with leading whitespace in the terminal. Flatten to a single consistent separator.

Suggested change
if (!accepted) {
const confirmDevTerms = await consoleCLI.prompt.promptConfirm(`${terms.text}\n\nYou have not accepted the Developer Terms of Service. Go to ${hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL)} to view the terms. Do you accept the terms? (y/n):`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Re-raised] trimEnd() was applied (vs the suggested trim()), so leading whitespace or newlines in API-controlled terms.text could still produce unexpected terminal output. trim() would be safer here.

Suggested change
if (!accepted) {
const termsText = terms.text ? terms.text.trim() : ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Re-raised] trimEnd() was applied (vs the suggested trim()), so leading whitespace or newlines in API-controlled terms.text could still produce unexpected terminal output. trim() would be safer here.

Suggested change
if (!accepted) {
const termsText = terms.text ? terms.text.trim() : ''

this.error('The Developer Terms of Service could not be accepted')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Re-raised] The prompt string contains a literal \n followed by \n (resulting in a double newline between terms text and the prompt message), which is intentional and fine, but the string also starts with ${terms.text} which may itself contain trailing newlines causing inconsistent terminal output. More critically, the raw \n in a template literal renders as a newline character which is correct — however the previous review flagged that the indentation of the source line (4 spaces before the closing backtick area) could cause leading whitespace. The real issue is the string is fine as-is for the newlines, but terms.text is user-controlled content from the API and is rendered directly into the terminal without any sanitization or length check, which could be a large wall of text overwhelming the prompt.

Suggested change
this.error('The Developer Terms of Service could not be accepted')
const termsText = terms.text ? terms.text.trim() : ''
const confirmDevTerms = await consoleCLI.prompt.promptConfirm(`${termsText}\n\nYou have not accepted the Developer Terms of Service. Go to ${hyperlinker(DEV_TERMS_URL, DEV_TERMS_URL)} to view the terms. Do you accept the terms? (y/n):`)

}
this.log(`The Developer Terms of Service were successfully accepted for org ${orgId}`)
}

/**
* Set console config
*
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/project/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CreateCommand extends ConsoleCommand {

await this.initSdk()
try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
// check name is not already in use
const projects = await this.consoleCLI.getProjects(orgId)
if (projects.find(project => project.name === projectDetails.name)) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/project/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ListCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const projects = await this.getConsoleOrgProjects(orgId)

if (flags.json) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/project/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SelectCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId)
const project = await this.selectProjectInteractive(orgId, args.projectIdOrName)

this.setConfig(CONFIG_KEYS.PROJECT, project)
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/publickey/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DeleteCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId)
const consoleConfig = await this.consoleCLI.getWorkspaceConfig(orgId, projectId, workspaceId)

const project = consoleConfig.project
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/publickey/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ListCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const consoleConfig = await this.consoleCLI.getWorkspaceConfig(orgId, projectId, workspaceId)

const project = consoleConfig.project
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/publickey/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class UploadAndBindCommand extends ConsoleCommand {

await this.initSdk()
try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const consoleConfig = await this.consoleCLI.getWorkspaceConfig(orgId, projectId, workspaceId)

const project = consoleConfig.project
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/api/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class AddCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const projects = await this.consoleCLI.getProjects(orgId)
const project = projects.find(p => p.name === flags.projectName)
if (!project) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/api/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ListCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const projects = await this.consoleCLI.getProjects(orgId)
const project = projects.find(p => p.name === flags.projectName)
if (!project) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CreateCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
// resolve project by name to project id
const projects = await this.consoleCLI.getProjects(orgId)
const project = projects.find(p => p.name === flags.projectName)
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class DownloadCommand extends ConsoleCommand {

await this.initSdk()
try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId)
const consoleConfig = await this.consoleCLI.getWorkspaceConfig(orgId, projectId, workspaceId)

let fileName = 'console.json'
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ListCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId, flags.json || flags.yml)
const workspaces = await this.getConsoleProjectWorkspaces(orgId, projectId)

if (flags.json) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/console/workspace/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SelectCommand extends ConsoleCommand {
await this.initSdk()

try {
await this.ensureDevTermAccepted(this.consoleCLI, orgId)
const workspace = await this.selectWorkspaceInteractive(orgId, projectId, args.workspaceIdOrName)

const obj = {
Expand Down
6 changes: 5 additions & 1 deletion test/commands/console/api/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const mockEnabledServices = [
]

const mockConsoleCLIInstance = {
getEnabledServicesForOrg: jest.fn().mockResolvedValue(mockEnabledServices)
getEnabledServicesForOrg: jest.fn().mockResolvedValue(mockEnabledServices),
checkDevTermsForOrg: jest.fn().mockResolvedValue(true),
getDevTermsForOrg: jest.fn().mockResolvedValue({ text: 'terms' }),
acceptDevTermsForOrg: jest.fn().mockResolvedValue(true),
prompt: { promptConfirm: jest.fn().mockResolvedValue(true) }
}

jest.mock('@adobe/aio-cli-lib-console', () => {
Expand Down
77 changes: 77 additions & 0 deletions test/commands/console/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,81 @@ describe('ConsoleCommand', () => {
expect(config.delete).toHaveBeenCalledWith(CONFIG_KEYS.CONSOLE)
})
})

describe('ensureDevTermAccepted', () => {
let mockConsoleCLI

beforeEach(() => {
mockConsoleCLI = {
checkDevTermsForOrg: jest.fn().mockResolvedValue(true),
getDevTermsForOrg: jest.fn().mockResolvedValue({ text: 'Developer Terms text' }),
acceptDevTermsForOrg: jest.fn().mockResolvedValue(true),
prompt: { promptConfirm: jest.fn().mockResolvedValue(true) }
}
command.error = jest.fn((msg) => { throw new Error(msg) })
command.log = jest.fn()
})

test('no-op when terms already accepted', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(true)
await command.ensureDevTermAccepted(mockConsoleCLI, 'org-1')
expect(mockConsoleCLI.checkDevTermsForOrg).toHaveBeenCalledWith('org-1')
expect(mockConsoleCLI.getDevTermsForOrg).not.toHaveBeenCalled()
expect(mockConsoleCLI.prompt.promptConfirm).not.toHaveBeenCalled()
expect(mockConsoleCLI.acceptDevTermsForOrg).not.toHaveBeenCalled()
expect(command.log).not.toHaveBeenCalled()
})

test('errors fast when terms not accepted and skipPrompts=true', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
await expect(command.ensureDevTermAccepted(mockConsoleCLI, 'org-1', true))
.rejects.toThrow(/Developer Terms of Service have not been accepted/)
expect(mockConsoleCLI.getDevTermsForOrg).not.toHaveBeenCalled()
expect(mockConsoleCLI.prompt.promptConfirm).not.toHaveBeenCalled()
})

test('errors when user declines the terms', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
mockConsoleCLI.prompt.promptConfirm.mockResolvedValue(false)
await expect(command.ensureDevTermAccepted(mockConsoleCLI, 'org-1'))
.rejects.toThrow('The Developer Terms of Service were declined')
expect(mockConsoleCLI.getDevTermsForOrg).toHaveBeenCalled()
expect(mockConsoleCLI.acceptDevTermsForOrg).not.toHaveBeenCalled()
})

test('accepts terms programmatically when user confirms', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
mockConsoleCLI.prompt.promptConfirm.mockResolvedValue(true)
mockConsoleCLI.acceptDevTermsForOrg.mockResolvedValue(true)
await command.ensureDevTermAccepted(mockConsoleCLI, 'org-1')
expect(mockConsoleCLI.acceptDevTermsForOrg).toHaveBeenCalledWith('org-1')
expect(command.log).toHaveBeenCalledWith(expect.stringContaining('successfully accepted'))
})

test('errors when accept call returns false', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
mockConsoleCLI.prompt.promptConfirm.mockResolvedValue(true)
mockConsoleCLI.acceptDevTermsForOrg.mockResolvedValue(false)
await expect(command.ensureDevTermAccepted(mockConsoleCLI, 'org-1'))
.rejects.toThrow('The Developer Terms of Service could not be accepted')
})

test('includes the terms URL in the prompt', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
mockConsoleCLI.getDevTermsForOrg.mockResolvedValue({ text: '\n Developer Terms text \n' })
await command.ensureDevTermAccepted(mockConsoleCLI, 'org-1')
const promptArg = mockConsoleCLI.prompt.promptConfirm.mock.calls[0][0]
expect(promptArg).toContain('https://www.adobe.com/go/developer-terms')
expect(promptArg).toContain('Developer Terms text')
expect(promptArg).toMatch(/^Developer Terms text\n\nYou have not accepted/)
})

test('handles missing terms text in the prompt', async () => {
mockConsoleCLI.checkDevTermsForOrg.mockResolvedValue(false)
mockConsoleCLI.getDevTermsForOrg.mockResolvedValue({})
await command.ensureDevTermAccepted(mockConsoleCLI, 'org-1')
const promptArg = mockConsoleCLI.prompt.promptConfirm.mock.calls[0][0]
expect(promptArg).toContain('You have not accepted the Developer Terms of Service.')
})
})
})
3 changes: 2 additions & 1 deletion test/commands/console/open.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.

const TestCommand = require('../../../src/commands/console/open')
const config = require('@adobe/aio-lib-core-config')
const { STAGE_ENV } = require('@adobe/aio-lib-env')
const { PROD_ENV, STAGE_ENV } = require('@adobe/aio-lib-env')

const mockOpen = jest.fn()
jest.unstable_mockModule('open', () => ({
Expand All @@ -25,6 +25,7 @@ beforeAll(() => {
ORIGINAL_AIO_CLI_ENV = process.env.AIO_CLI_ENV
})
beforeEach(() => {
process.env.AIO_CLI_ENV = PROD_ENV
config.get.mockReset()
mockOpen.mockReset()
command = new TestCommand([])
Expand Down
7 changes: 6 additions & 1 deletion test/commands/console/project/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const mockProject = {

const mockConsoleCLIInstance = {
getProjects: jest.fn().mockResolvedValue([]),
createProject: jest.fn().mockResolvedValue(mockProject)
createProject: jest.fn().mockResolvedValue(mockProject),
checkDevTermsForOrg: jest.fn().mockResolvedValue(true),
getDevTermsForOrg: jest.fn().mockResolvedValue({ text: 'terms' }),
acceptDevTermsForOrg: jest.fn().mockResolvedValue(true),
prompt: { promptConfirm: jest.fn().mockResolvedValue(true) }
}

jest.mock('@adobe/aio-cli-lib-console', () => ({
Expand All @@ -46,6 +50,7 @@ describe('console:project:create', () => {
mockConsoleCLIInstance.createProject = jest.fn().mockResolvedValue(mockProject)
mockConsoleCLIInstance.getProjects.mockReset()
mockConsoleCLIInstance.getProjects = jest.fn().mockResolvedValue([])
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
})

afterEach(() => {
Expand Down
13 changes: 13 additions & 0 deletions test/commands/console/project/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const mockConsoleCLIInstance = {}
*/
function setDefaultMockConsoleCLI () {
mockConsoleCLIInstance.getProjects = jest.fn().mockResolvedValue(projects)
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.getDevTermsForOrg = jest.fn().mockResolvedValue({ text: 'terms' })
mockConsoleCLIInstance.acceptDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.prompt = { promptConfirm: jest.fn().mockResolvedValue(true) }
}
jest.mock('@adobe/aio-cli-lib-console', () => ({
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
Expand Down Expand Up @@ -117,6 +121,15 @@ describe('console:project:list', () => {
expect(mockConsoleCLIInstance.getProjects).toHaveBeenCalledWith('1001')
})

test('should not prompt for developer terms when returning projects as json', async () => {
mockConsoleCLIInstance.checkDevTermsForOrg.mockResolvedValue(false)
command.argv = ['--orgId', '1001', '--json']

await expect(command.run()).rejects.toThrow('Developer Terms of Service have not been accepted')
expect(mockConsoleCLIInstance.prompt.promptConfirm).not.toHaveBeenCalled()
expect(mockConsoleCLIInstance.getProjects).not.toHaveBeenCalled()
})

test('should return list of projects yaml', async () => {
command.argv = ['--orgId', '1001', '--yml']
await expect(command.run()).resolves.not.toThrow()
Expand Down
4 changes: 4 additions & 0 deletions test/commands/console/project/select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const mockConsoleCLIInstance = {}
function setDefaultMockConsoleCLI () {
mockConsoleCLIInstance.getProjects = jest.fn().mockResolvedValue(projects)
mockConsoleCLIInstance.promptForSelectProject = jest.fn().mockResolvedValue(selectedProject)
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.getDevTermsForOrg = jest.fn().mockResolvedValue({ text: 'terms' })
mockConsoleCLIInstance.acceptDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.prompt = { promptConfirm: jest.fn().mockResolvedValue(true) }
}

jest.mock('@adobe/aio-cli-lib-console', () => ({
Expand Down
4 changes: 4 additions & 0 deletions test/commands/console/publickey/delete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function setDefaultMockConsoleCLI () {
mockConsoleCLIInstance.getWorkspaceConfig = jest.fn().mockResolvedValue(consoleConfig)
mockConsoleCLIInstance.getBindingsForWorkspace = jest.fn().mockResolvedValue([binding1, binding2])
mockConsoleCLIInstance.deleteBindingFromWorkspace = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.getDevTermsForOrg = jest.fn().mockResolvedValue({ text: 'terms' })
mockConsoleCLIInstance.acceptDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.prompt = { promptConfirm: jest.fn().mockResolvedValue(true) }
}
jest.mock('@adobe/aio-cli-lib-console', () => ({
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
Expand Down
4 changes: 4 additions & 0 deletions test/commands/console/publickey/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const mockConsoleCLIInstance = {}
function setDefaultMockConsoleCLI () {
mockConsoleCLIInstance.getWorkspaceConfig = jest.fn().mockResolvedValue(consoleConfig)
mockConsoleCLIInstance.getBindingsForWorkspace = jest.fn().mockResolvedValue(bindings)
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.getDevTermsForOrg = jest.fn().mockResolvedValue({ text: 'terms' })
mockConsoleCLIInstance.acceptDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.prompt = { promptConfirm: jest.fn().mockResolvedValue(true) }
}
jest.mock('@adobe/aio-cli-lib-console', () => ({
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
Expand Down
4 changes: 4 additions & 0 deletions test/commands/console/publickey/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function setDefaultMockConsoleCLI () {
mockConsoleCLIInstance.getBindingsForWorkspace = jest.fn().mockResolvedValue([binding1])
mockConsoleCLIInstance.uploadAndBindCertificateToWorkspace = jest.fn().mockResolvedValue(binding2)
mockConsoleCLIInstance.getCertificateFingerprint = jest.fn().mockResolvedValue({ certificateFingerprint: 'cf2' })
mockConsoleCLIInstance.checkDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.getDevTermsForOrg = jest.fn().mockResolvedValue({ text: 'terms' })
mockConsoleCLIInstance.acceptDevTermsForOrg = jest.fn().mockResolvedValue(true)
mockConsoleCLIInstance.prompt = { promptConfirm: jest.fn().mockResolvedValue(true) }
}
jest.mock('@adobe/aio-cli-lib-console', () => ({
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
Expand Down
6 changes: 5 additions & 1 deletion test/commands/console/workspace/api/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ const mockConsoleCLIInstance = {
getWorkspaces: jest.fn().mockResolvedValue([mockWorkspace]),
getEnabledServicesForOrg: jest.fn().mockResolvedValue(mockEnabledServices),
getServicePropertiesFromWorkspaceWithCredentialType: jest.fn().mockResolvedValue([]),
subscribeToServicesWithCredentialType: jest.fn().mockResolvedValue(mockSubscribeResponse)
subscribeToServicesWithCredentialType: jest.fn().mockResolvedValue(mockSubscribeResponse),
checkDevTermsForOrg: jest.fn().mockResolvedValue(true),
getDevTermsForOrg: jest.fn().mockResolvedValue({ text: 'terms' }),
acceptDevTermsForOrg: jest.fn().mockResolvedValue(true),
prompt: { promptConfirm: jest.fn().mockResolvedValue(true) }
}

jest.mock('@adobe/aio-cli-lib-console', () => ({
Expand Down
6 changes: 5 additions & 1 deletion test/commands/console/workspace/api/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const mockConsoleCLIInstance = {
getProjects: jest.fn().mockResolvedValue([mockProject]),
getWorkspaces: jest.fn().mockResolvedValue([mockWorkspace]),
getEnabledServicesForOrg: jest.fn().mockResolvedValue(mockEnabledServices),
getServicePropertiesFromWorkspaceWithCredentialType: jest.fn().mockResolvedValue(mockSubscribedServiceProperties)
getServicePropertiesFromWorkspaceWithCredentialType: jest.fn().mockResolvedValue(mockSubscribedServiceProperties),
checkDevTermsForOrg: jest.fn().mockResolvedValue(true),
getDevTermsForOrg: jest.fn().mockResolvedValue({ text: 'terms' }),
acceptDevTermsForOrg: jest.fn().mockResolvedValue(true),
prompt: { promptConfirm: jest.fn().mockResolvedValue(true) }
}

jest.mock('@adobe/aio-cli-lib-console', () => {
Expand Down
Loading
Loading