sql proj - publish to docker improvements (#17124)

This commit is contained in:
Leila Lali
2021-09-21 16:47:06 -07:00
committed by GitHub
parent 9bdb7f49b1
commit 3ed611db66
7 changed files with 113 additions and 23 deletions

View File

@@ -88,6 +88,27 @@ describe('deploy service', function (): void {
});
it('Should deploy fails if docker is not running', async function (): Promise<void> {
const testContext = createContext();
const deployProfile: IDeployProfile = {
localDbSetting: {
dbName: 'test',
password: 'PLACEHOLDER',
port: 1433,
serverName: 'localhost',
userName: 'sa',
dockerBaseImage: 'image',
connectionRetryTimeout: 1
}
};
const projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
const project1 = await Project.openProject(vscode.Uri.file(projFilePath).fsPath);
const deployService = new DeployService(testContext.outputChannel);
sandbox.stub(azdata.tasks, 'startBackgroundOperation').callThrough();
sandbox.stub(childProcess, 'exec').throws('error');
await should(deployService.deploy(deployProfile, project1)).rejected();
});
it('Should retry connecting to the server', async function (): Promise<void> {
const testContext = createContext();
const localDbSettings = {

View File

@@ -7,7 +7,7 @@ import * as should from 'should';
import * as path from 'path';
import * as os from 'os';
import { createDummyFileStructure } from './testUtils';
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion, validateSqlServerPortNumber, isEmptyString, detectCommandInstallation } from '../common/utils';
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion, validateSqlServerPortNumber, isEmptyString, detectCommandInstallation, isValidSQLPassword } from '../common/utils';
import { Uri } from 'vscode';
describe('Tests to verify utils functions', function (): void {
@@ -110,5 +110,18 @@ describe('Tests to verify utils functions', function (): void {
should(await detectCommandInstallation('node')).equal(true, '"node" should have been detected.');
should(await detectCommandInstallation('bogusFakeCommand')).equal(false, '"bogusFakeCommand" should have been detected.');
});
it('Should validate SQL server password correctly', () => {
should(isValidSQLPassword('invalid')).equals(false, 'string with chars only is invalid password');
should(isValidSQLPassword('')).equals(false, 'empty string is invalid password');
should(isValidSQLPassword('65536')).equals(false, 'string with numbers only is invalid password');
should(isValidSQLPassword('dFGj')).equals(false, 'string with lowercase and uppercase char only is invalid password');
should(isValidSQLPassword('dj$')).equals(false, 'string with char and symbols only is invalid password');
should(isValidSQLPassword('dF65530')).equals(false, 'string with char and numbers only is invalid password');
should(isValidSQLPassword('dF6$30')).equals(false, 'dF6$30 is invalid password');
should(isValidSQLPassword('dF65$530')).equals(true, 'dF65$530 is valid password');
should(isValidSQLPassword('dFdf65$530')).equals(true, 'dF65$530 is valid password');
should(isValidSQLPassword('av1fgh533@')).equals(true, 'dF65$530 is valid password');
});
});