File tree Expand file tree Collapse file tree 4 files changed +7444
-7612
lines changed
amplify-opensearch-simulator Expand file tree Collapse file tree 4 files changed +7444
-7612
lines changed Original file line number Diff line number Diff line change 44
55``` ts
66
7- /// <reference types = " node" />
8-
97import { $TSAny } from ' @aws-amplify/amplify-cli-core' ;
108import execa from ' execa' ;
119import { GetPackageAssetPaths } from ' @aws-amplify/amplify-cli-core' ;
Original file line number Diff line number Diff line change @@ -135,6 +135,35 @@ describe('Test Mock API methods', () => {
135135 await expect ( mockContext . print . error ) . toHaveBeenCalledWith ( 'Failed to start API Mocking.' ) ;
136136 } ) ;
137137
138+ it ( 'shows error message and resolution when https enabled if SSL key and certificate paths are not provided' , async ( ) => {
139+ ConfigOverrideManager . getInstance = jest . fn ( ) . mockReturnValue ( jest . fn ) ;
140+ const mockContext = {
141+ print : {
142+ red : jest . fn ( ) ,
143+ green : jest . fn ( ) ,
144+ error : jest . fn ( ) ,
145+ } ,
146+ parameters : {
147+ options : {
148+ help : false ,
149+ } ,
150+ } ,
151+ input : {
152+ argv : [ '--https' ] ,
153+ } ,
154+ amplify : {
155+ getEnvInfo : jest . fn ( ) . mockReturnValue ( { projectPath : mockProjectRoot } ) ,
156+ pathManager : {
157+ getGitIgnoreFilePath : jest . fn ( ) ,
158+ } ,
159+ } ,
160+ } as unknown as $TSContext ;
161+ await run ( mockContext ) ;
162+ await expect ( mockContext . print . error ) . toHaveBeenCalledWith (
163+ '\nThe --https option must be followed by the path to the SSL key and the path to the SSL certificate.\n' ,
164+ ) ;
165+ } ) ;
166+
138167 it ( 'attempts to set custom port correctly' , async ( ) => {
139168 const GRAPHQL_PORT = 8081 ;
140169 const mockContext = {
Original file line number Diff line number Diff line change 11export function getHttpsConfig ( context ) : { sslKeyPath : string | undefined ; sslCertPath : string | undefined } {
22 const paths : { sslKeyPath : string | undefined ; sslCertPath : string | undefined } = { sslKeyPath : undefined , sslCertPath : undefined } ;
3+
4+ if ( ! context . input || ! context . input . argv ) {
5+ return paths ;
6+ }
7+
38 const argv = context . input . argv ;
49 const httpsIndex = argv . indexOf ( '--https' ) ;
510
You can’t perform that action at this time.
0 commit comments