Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a00d96a
fix: add environment setup step to integration tests workflow
devin-ai-integration[bot] Feb 8, 2025
9f50c60
fix: add test:integration script to package.json
devin-ai-integration[bot] Feb 8, 2025
941964e
fix: add integration test files
devin-ai-integration[bot] Feb 8, 2025
58596b9
fix: update test script to exclude integration tests
devin-ai-integration[bot] Feb 8, 2025
fd8e40e
fix: update test script to include specific test directories
devin-ai-integration[bot] Feb 8, 2025
9499e63
fix: update test script pattern to properly exclude integration tests
devin-ai-integration[bot] Feb 8, 2025
6c1e5fe
fix: update test script to use explicit directory pattern
devin-ai-integration[bot] Feb 8, 2025
4843b96
fix: update test script to use explicit test directories
devin-ai-integration[bot] Feb 8, 2025
6a364e9
fix: add environment variable validation to integration test workflow
devin-ai-integration[bot] Feb 8, 2025
ef2c22e
fix: update test script to properly exclude integration tests
devin-ai-integration[bot] Feb 8, 2025
67a3db2
fix: update test script to use mocha ignore flag
devin-ai-integration[bot] Feb 8, 2025
a8924cd
fix: update test script to use mocha exclude flag
devin-ai-integration[bot] Feb 8, 2025
b055c49
fix: update test script to use explicit directories and negation pattern
devin-ai-integration[bot] Feb 8, 2025
fc4b3eb
fix: update test script to use explicit test directories only
devin-ai-integration[bot] Feb 8, 2025
efddd23
fix: update test script to use recursive flag with specific directories
devin-ai-integration[bot] Feb 8, 2025
f09dee3
fix: add test setup file to skip integration tests when env vars are …
devin-ai-integration[bot] Feb 8, 2025
892a44f
fix: move integration tests to separate directory
devin-ai-integration[bot] Feb 8, 2025
fd69725
fix: update lint script to include integration-tests directory
devin-ai-integration[bot] Feb 8, 2025
7193f91
fix: update import path in test helper
devin-ai-integration[bot] Feb 8, 2025
a6bf9d9
fix: add eslint config for integration tests
devin-ai-integration[bot] Feb 8, 2025
db9aabc
fix: update CLI path to handle CI environment
devin-ai-integration[bot] Feb 8, 2025
9272f9c
fix: resolve lint issues in test helper
devin-ai-integration[bot] Feb 8, 2025
7c0fd18
style: fix async function formatting in users test
devin-ai-integration[bot] Feb 8, 2025
2aac487
test: add user integration tests with working get and groups commands
devin-ai-integration[bot] Feb 8, 2025
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
41 changes: 41 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: integration-tests
on:
pull_request:
types: [opened, synchronize]
branches:
- main
push:
branches:
- main

jobs:
integration-test:
runs-on: ubuntu-latest
name: Integration Tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20'
- name: npm install
run: npm install
- name: Setup Integration Test Environment
env:
BOX_JWT_CONFIG: ${{ secrets.BOX_JWT_CONFIG }}
BOX_ADMIN_USER_ID: ${{ secrets.BOX_ADMIN_USER_ID }}
run: |
if [ -z "$BOX_JWT_CONFIG" ] || [ -z "$BOX_ADMIN_USER_ID" ]; then
echo "Missing required environment variables"
exit 1
fi
mkdir -p ~/.box
chmod 700 ~/.box
echo '{"cacheTokens":true,"boxReportsFolderPath":"/tmp/box-reports","boxDownloadsFolderPath":"/tmp/box-downloads"}' > ~/.box/settings.json
chmod 600 ~/.box/settings.json
- name: Run Integration Tests
env:
BOX_JWT_CONFIG: ${{ secrets.BOX_JWT_CONFIG }}
BOX_ADMIN_USER_ID: ${{ secrets.BOX_ADMIN_USER_ID }}
run: npm run test:integration
9 changes: 9 additions & 0 deletions integration-tests/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
extends: '../.eslintrc.yml'

env:
mocha: true

rules:
require-jsdoc: off
no-unused-expressions: off # needed for chai assertions
172 changes: 172 additions & 0 deletions integration-tests/__tests__/users.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
'use strict';

const { expect } = require('chai');
const { execCLI, getAdminUserId, setupEnvironment, cleanupEnvironment, getJWTConfig } = require('../helpers/test-helper');

describe('Users Integration Tests', () => {
let adminUserId;
let testUser;
let testUserEmail;

beforeEach(async() => {
adminUserId = getAdminUserId();
testUserEmail = `test-user-${Date.now()}@boxdemo.com`;
await setupEnvironment();
});

after(async() => {
try {
if (testUser) {
await execCLI(`users:delete ${testUser.id} --force`);
}
} finally {
await cleanupEnvironment();
}
});

describe('User Lifecycle', () => {
it('should create and delete a user', async() => {
const createOutput = await execCLI(`users:create "${testUserEmail}" ${testUserEmail} --json`);
testUser = JSON.parse(createOutput);
expect(testUser).to.be.an('object');
expect(testUser.login).to.equal(testUserEmail);
expect(testUser.name).to.equal(testUserEmail);

const deleteOutput = await execCLI(`users:delete ${testUser.id} --force --json`);
expect(deleteOutput).to.include('Successfully deleted user');
testUser = null;
});

it('should update user info', async() => {
const createOutput = await execCLI(`users:create "${testUserEmail}" ${testUserEmail} --json`);
testUser = JSON.parse(createOutput);

const newName = 'Updated Name';
const updateOutput = await execCLI(`users:update ${testUser.id} --name="${newName}" --json`);
const updatedUser = JSON.parse(updateOutput);
expect(updatedUser.name).to.equal(newName);
});

it('should manage email aliases', async() => {
const createOutput = await execCLI(`users:create "${testUserEmail}" ${testUserEmail} --json`);
testUser = JSON.parse(createOutput);

const aliasEmail = `alias-${Date.now()}@boxdemo.com`;
await execCLI(`users:email-aliases:add ${testUser.id} ${aliasEmail}`);

const listOutput = await execCLI(`users:email-aliases ${testUser.id} --json`);
const aliases = JSON.parse(listOutput);
expect(aliases).to.be.an('array');
expect(aliases.some(alias => alias.email === aliasEmail)).to.be.true;

await execCLI(`users:email-aliases:remove ${testUser.id} ${aliasEmail}`);
const updatedListOutput = await execCLI(`users:email-aliases ${testUser.id} --json`);
const updatedAliases = JSON.parse(updatedListOutput);
expect(updatedAliases.some(alias => alias.email === aliasEmail)).to.be.false;
});
});

describe('User Operations', () => {
it('should get user info', async() => {
const output = await execCLI(`users:get ${adminUserId} --json`);
const user = JSON.parse(output);
expect(user).to.be.an('object');
expect(user.id).to.equal(adminUserId);
expect(user.type).to.equal('user');
expect(user.login).to.be.a('string');
expect(user.name).to.be.a('string');
expect(user.created_at).to.be.a('string');
expect(user.modified_at).to.be.a('string');
});

it('should list group memberships', async() => {
const output = await execCLI(`users:groups ${adminUserId} --json`);
const memberships = JSON.parse(output);
expect(memberships).to.be.an('array');
memberships.forEach(membership => {
expect(membership.type).to.equal('group_membership');
expect(membership.user.id).to.equal(adminUserId);
expect(membership.group).to.be.an('object');
});
});

it('should search users', async() => {
const createOutput = await execCLI(`users:create "${testUserEmail}" ${testUserEmail} --json`);
testUser = JSON.parse(createOutput);

const searchOutput = await execCLI(`users:search ${testUserEmail} --json`);
const searchResults = JSON.parse(searchOutput);
expect(searchResults).to.be.an('array');
expect(searchResults.some(user => user.id === testUser.id)).to.be.true;
});

it('should terminate user sessions', async() => {
const createOutput = await execCLI(`users:create "${testUserEmail}" ${testUserEmail} --json`);
testUser = JSON.parse(createOutput);

const output = await execCLI(`users:terminate-session ${testUser.id}`);
expect(output).to.include('Successfully terminated user sessions');
});
});

describe('Content Transfer', () => {
let sourceUser;
let destinationUser;

beforeEach(async() => {
// Create source user
const sourceEmail = `test-source-${Date.now()}@boxdemo.com`;
const sourceOutput = await execCLI(`users:create "${sourceEmail}" ${sourceEmail} --json`);
sourceUser = JSON.parse(sourceOutput);

// Create destination user
const destEmail = `test-dest-${Date.now()}@boxdemo.com`;
const destOutput = await execCLI(`users:create "${destEmail}" ${destEmail} --json`);
destinationUser = JSON.parse(destOutput);
});

afterEach(async() => {
// Clean up test users
if (sourceUser) {
await execCLI(`users:delete ${sourceUser.id} --force`);
}
if (destinationUser) {
await execCLI(`users:delete ${destinationUser.id} --force`);
}
});

it('should transfer content between users', async() => {
const output = await execCLI(`users:transfer-content ${sourceUser.id} ${destinationUser.id} --json`);
const result = JSON.parse(output);
expect(result.owned_by.id).to.equal(destinationUser.id);
expect(result.type).to.equal('folder');
});

it('should transfer content with notify flag', async() => {
const output = await execCLI(`users:transfer-content ${sourceUser.id} ${destinationUser.id} --notify --json`);
const result = JSON.parse(output);
expect(result.owned_by.id).to.equal(destinationUser.id);
expect(result.type).to.equal('folder');
});
});

describe('User Invitations', () => {
let testEmail;
let enterpriseId;

beforeEach(() => {
testEmail = `test-invite-${Date.now()}@boxdemo.com`;
// Get enterprise ID from JWT config
const jwtConfig = getJWTConfig();
enterpriseId = jwtConfig.enterpriseID;
});

it('should invite a user to enterprise', async() => {
const output = await execCLI(`users:invite ${testEmail} ${enterpriseId} --json`);
const result = JSON.parse(output);
expect(result.enterprise.id).to.equal(enterpriseId);
expect(result.actionable_by.login).to.equal(testEmail);
expect(result.status).to.equal('pending');
});
});
});
Loading
Loading