@rockcarver/frodo-lib 0.17.0 → 0.17.2-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"State.js","names":["__dirname","path","dirname","fileURLToPath","pkg","JSON","parse","fs","readFileSync","resolve","_state","authenticationHeaderOverrides","setHost","host","getHost","process","env","FRODO_HOST","setTenant","getTenant","setUsername","username","getUsername","FRODO_USERNAME","setPassword","password","getPassword","FRODO_PASSWORD","setRealm","realm","getRealm","FRODO_REALM","setDeploymentType","type","deploymentType","getDeploymentType","setAllowInsecureConnection","allowInsecureConnection","getAllowInsecureConnection","setCookieName","name","cookieName","getCookieName","setCookieValue","value","cookieValue","getCookieValue","setAuthenticationHeaderOverrides","overrides","getAuthenticationHeaderOverrides","setAuthenticationService","service","authenticationService","getAuthenticationService","setServiceAccountId","uuid","serviceAccountId","getServiceAccountId","FRODO_SA_ID","setServiceAccountJwk","jwk","serviceAccountJwk","getServiceAccountJwk","FRODO_SA_JWK","undefined","setUseBearerTokenForAmApis","useBearerTokenForAmApis","getUseBearerTokenForAmApis","setBearerToken","token","bearerToken","getBearerToken","setLogApiKey","key","logApiKey","getLogApiKey","FRODO_LOG_KEY","setLogApiSecret","secret","logApiSecret","getLogApiSecret","FRODO_LOG_SECRET","setAmVersion","version","amVersion","getAmVersion","setFrodoVersion","frodoVersion","getFrodoVersion","setConnectionProfilesPath","connectionProfilesPath","getConnectionProfilesPath","setMasterKeyPath","masterKeyPath","getMasterKeyPath","setOutputFile","file","outputFile","getOutputFile","setDirectory","directory","getDirectory","setPrintHandler","handler","printHandler","getPrintHandler","setVerboseHandler","verboseHandler","getVerboseHandler","setVerbose","verbose","getVerbose","setDebugHandler","debugHandler","getDebugHandler","setDebug","debug","getDebug","FRODO_DEBUG","setCurlirizeHandler","curlirizeHandler","getCurlirizeHandler","setCurlirize","curlirize","getCurlirize","setCreateProgressHandler","createProgressHandler","getCreateProgressHandler","setUpdateProgressHandler","updateProgressHandler","getUpdateProgressHandler","setStopProgressHandler","stopProgressHandler","getStopProgressHandler","session"],"sources":["shared/State.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { JwkRsa } from '../ops/JoseOps';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nexport interface StateInterface {\n // connection settings\n host?: string;\n username?: string;\n password?: string;\n realm?: string;\n deploymentType?: string;\n allowInsecureConnection?: boolean;\n // customize authentication\n authenticationHeaderOverrides?: Record<string, string>;\n authenticationService?: string;\n // cookie settings\n cookieName?: string;\n cookieValue?: string;\n // service account settings\n serviceAccountId?: string;\n serviceAccountJwk?: JwkRsa;\n // bearer token settings\n useBearerTokenForAmApis?: boolean;\n bearerToken?: string;\n // log api settings\n logApiKey?: string;\n logApiSecret?: string;\n // versions\n amVersion?: string;\n frodoVersion?: string;\n // miscellaneous settings\n connectionProfilesPath?: string;\n masterKeyPath?: string;\n outputFile?: string;\n directory?: string;\n // output handler settings\n printHandler?: (\n message: string | object,\n type?: string,\n newline?: boolean\n ) => void;\n verboseHandler?: (message: string | object) => void;\n verbose?: boolean;\n debugHandler?: (message: string | object) => void;\n debug?: boolean;\n curlirizeHandler?: (message: string) => void;\n curlirize?: boolean;\n createProgressHandler?: (\n type: string,\n total?: number,\n message?: string\n ) => void;\n updateProgressHandler?: (message: string) => void;\n stopProgressHandler?: (message: string, status?: string) => void;\n}\n\nconst _state: StateInterface = {\n authenticationHeaderOverrides: {},\n};\n\nexport const setHost = (host: string) => (_state.host = host);\nexport const getHost = () => _state.host || process.env.FRODO_HOST;\n\n/**\n * @deprecated since v0.17.0 use `setHost(host: string)` instead\n */\nexport const setTenant = setHost;\n/**\n * @deprecated since v0.17.0 use `getHost` instead\n */\nexport const getTenant = getHost;\n\nexport const setUsername = (username: string) => (_state.username = username);\nexport const getUsername = () => _state.username || process.env.FRODO_USERNAME;\n\nexport const setPassword = (password: string) => (_state.password = password);\nexport const getPassword = () => _state.password || process.env.FRODO_PASSWORD;\n\nexport const setRealm = (realm: string) => (_state.realm = realm);\nexport const getRealm = () => _state.realm || process.env.FRODO_REALM;\n\nexport const setDeploymentType = (type: string) =>\n (_state.deploymentType = type);\nexport const getDeploymentType = () => _state.deploymentType;\n\nexport const setAllowInsecureConnection = (allowInsecureConnection: boolean) =>\n (_state.allowInsecureConnection = allowInsecureConnection);\nexport const getAllowInsecureConnection = () =>\n _state['allowInsecureConnection'];\n\nexport const setCookieName = (name: string) => (_state.cookieName = name);\nexport const getCookieName = () => _state.cookieName;\nexport const setCookieValue = (value: string) => (_state.cookieValue = value);\nexport const getCookieValue = () => _state.cookieValue;\n\nexport const setAuthenticationHeaderOverrides = (\n overrides: Record<string, string>\n) => (_state.authenticationHeaderOverrides = overrides);\nexport const getAuthenticationHeaderOverrides = () =>\n _state.authenticationHeaderOverrides;\nexport const setAuthenticationService = (service: string) =>\n (_state.authenticationService = service);\nexport const getAuthenticationService = () => _state.authenticationService;\n\nexport const setServiceAccountId = (uuid: string) =>\n (_state.serviceAccountId = uuid);\nexport const getServiceAccountId = (): string =>\n _state.serviceAccountId || process.env.FRODO_SA_ID;\nexport const setServiceAccountJwk = (jwk: JwkRsa) =>\n (_state.serviceAccountJwk = { ...jwk });\nexport const getServiceAccountJwk = (): JwkRsa =>\n _state.serviceAccountJwk ||\n (process.env.FRODO_SA_JWK ? JSON.parse(process.env.FRODO_SA_JWK) : undefined);\n\nexport const setUseBearerTokenForAmApis = (useBearerTokenForAmApis: boolean) =>\n (_state.useBearerTokenForAmApis = useBearerTokenForAmApis);\nexport const getUseBearerTokenForAmApis = () => _state.useBearerTokenForAmApis;\nexport const setBearerToken = (token: string) => (_state.bearerToken = token);\nexport const getBearerToken = () => _state.bearerToken;\n\nexport const setLogApiKey = (key: string) => (_state.logApiKey = key);\nexport const getLogApiKey = () => _state.logApiKey || process.env.FRODO_LOG_KEY;\nexport const setLogApiSecret = (secret: string) =>\n (_state.logApiSecret = secret);\nexport const getLogApiSecret = () =>\n _state.logApiSecret || process.env.FRODO_LOG_SECRET;\n\nexport const setAmVersion = (version: string) => (_state.amVersion = version);\nexport const getAmVersion = () => _state.amVersion;\n\nexport const setFrodoVersion = (version: string) =>\n (_state.frodoVersion = version);\nexport const getFrodoVersion = () =>\n _state.frodoVersion || `v${pkg.version} [${process.version}]`;\n\nexport const setConnectionProfilesPath = (path: string) =>\n (_state.connectionProfilesPath = path);\nexport const getConnectionProfilesPath = () => _state.connectionProfilesPath;\n\nexport const setMasterKeyPath = (path: string) => (_state.masterKeyPath = path);\nexport const getMasterKeyPath = () => _state.masterKeyPath;\n\nexport const setOutputFile = (file: string) => (_state.outputFile = file);\nexport const getOutputFile = () => _state.outputFile;\n\nexport const setDirectory = (directory: string) =>\n (_state.directory = directory);\nexport const getDirectory = () => _state.directory;\n\nexport const setPrintHandler = (\n handler: (message: string | object, type?: string, newline?: boolean) => void\n) => (_state.printHandler = handler);\nexport const getPrintHandler = () => _state.printHandler;\n\nexport const setVerboseHandler = (\n handler: (message: string | object) => void\n) => (_state.verboseHandler = handler);\nexport const getVerboseHandler = () => _state.verboseHandler;\nexport const setVerbose = (verbose: boolean) => (_state.verbose = verbose);\nexport const getVerbose = (): boolean => _state.verbose;\n\nexport const setDebugHandler = (handler: (message: string | object) => void) =>\n (_state.debugHandler = handler);\nexport const getDebugHandler = () => _state.debugHandler;\nexport const setDebug = (debug: boolean) => (_state.debug = debug);\nexport const getDebug = (): boolean =>\n _state.debug || process.env.FRODO_DEBUG !== undefined;\n\nexport const setCurlirizeHandler = (handler: (message: string) => void) =>\n (_state.curlirizeHandler = handler);\nexport const getCurlirizeHandler = () => _state.curlirizeHandler;\nexport const setCurlirize = (curlirize: boolean) =>\n (_state.curlirize = curlirize);\nexport const getCurlirize = (): boolean => _state.curlirize;\n\nexport const setCreateProgressHandler = (\n handler: (type: string, total?: number, message?: string) => void\n) => (_state.createProgressHandler = handler);\nexport const getCreateProgressHandler = () => _state.createProgressHandler;\nexport const setUpdateProgressHandler = (handler: (message: string) => void) =>\n (_state.updateProgressHandler = handler);\nexport const getUpdateProgressHandler = () => _state.updateProgressHandler;\nexport const setStopProgressHandler = (\n handler: (message: string, status?: string) => void\n) => (_state.stopProgressHandler = handler);\nexport const getStopProgressHandler = () => _state.stopProgressHandler;\n\n/**\n * @deprecated since version v0.17.0. Import state:\n *\n * ```import { state } from '@rockcarver/frodo-lib';```\n *\n * then call functions:\n *\n * ```const username = state.getUsername();```\n */\nexport default {\n session: {\n setHost,\n getHost,\n\n setTenant,\n getTenant,\n\n setUsername,\n getUsername,\n\n setPassword,\n getPassword,\n\n setRealm,\n getRealm,\n\n setDeploymentType,\n getDeploymentType,\n\n setAllowInsecureConnection,\n getAllowInsecureConnection,\n\n setCookieName,\n getCookieName,\n setCookieValue,\n getCookieValue,\n\n setAuthenticationHeaderOverrides,\n getAuthenticationHeaderOverrides,\n setAuthenticationService,\n getAuthenticationService,\n\n setServiceAccountId,\n getServiceAccountId,\n setServiceAccountJwk,\n getServiceAccountJwk,\n\n setUseBearerTokenForAmApis,\n getUseBearerTokenForAmApis,\n setBearerToken,\n getBearerToken,\n\n setLogApiKey,\n getLogApiKey,\n setLogApiSecret,\n getLogApiSecret,\n\n setAmVersion,\n getAmVersion,\n\n setFrodoVersion,\n getFrodoVersion,\n\n setConnectionProfilesPath,\n getConnectionProfilesPath,\n\n setMasterKeyPath,\n getMasterKeyPath,\n\n setOutputFile,\n getOutputFile,\n\n setDirectory,\n getDirectory,\n\n setPrintHandler,\n getPrintHandler,\n\n setVerboseHandler,\n getVerboseHandler,\n setVerbose,\n getVerbose,\n\n setDebugHandler,\n getDebugHandler,\n setDebug,\n getDebug,\n\n setCurlirizeHandler,\n getCurlirizeHandler,\n setCurlirize,\n getCurlirize,\n\n setCreateProgressHandler,\n getCreateProgressHandler,\n setUpdateProgressHandler,\n getUpd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IAC1BE,0BAA0B;IAC1BC,cAAc;IACdG,cAAc;IAEdC,YAAY;IACZG,YAAY;IACZE,eAAe;IACfG,eAAe;IAEfE,YAAY;IACZG,YAAY;IAEZC,eAAe;IACfE,eAAe;IAEfC,yBAAyB;IACzBE,yBAAyB;IAEzBC,gBAAgB;IAChBE,gBAAgB;IAEhBC,aAAa;IACbG,aAAa;IAEbC,YAAY;IACZE,YAAY;IAEZC,eAAe;IACfG,eAAe;IAEfC,iBAAiB;IACjBE,iBAAiB;IACjBC,UAAU;IACVE,UAAU;IAEVC,eAAe;IACfE,eAAe;IACfC,QAAQ;IACRE,QAAQ;IAERE,mBAAmB;IACnBE,mBAAmB;IACnBC,YAAY;IACZE,YAAY;IAEZC,wBAAwB;IACxBE,wBAAwB;IACxBC,wBAAwB;IACxBE,wBAAwB;IACxBC,sBAAsB;IACtBE;EACF;AACF,CAAC;AAAA"}
1
+ {"version":3,"file":"State.js","names":["__dirname","path","dirname","fileURLToPath","pkg","JSON","parse","fs","readFileSync","resolve","_state","authenticationHeaderOverrides","printHandler","message","console","dir","depth","log","verboseHandler","getVerbose","debugHandler","getDebug","curlirizeHandler","setHost","host","getHost","process","env","FRODO_HOST","setTenant","getTenant","setUsername","username","getUsername","FRODO_USERNAME","setPassword","password","getPassword","FRODO_PASSWORD","setRealm","realm","getRealm","FRODO_REALM","setDeploymentType","type","deploymentType","getDeploymentType","setAllowInsecureConnection","allowInsecureConnection","getAllowInsecureConnection","setCookieName","name","cookieName","getCookieName","setCookieValue","value","cookieValue","getCookieValue","setAuthenticationHeaderOverrides","overrides","getAuthenticationHeaderOverrides","setAuthenticationService","service","authenticationService","getAuthenticationService","setServiceAccountId","uuid","serviceAccountId","getServiceAccountId","FRODO_SA_ID","setServiceAccountJwk","jwk","serviceAccountJwk","getServiceAccountJwk","FRODO_SA_JWK","undefined","setUseBearerTokenForAmApis","useBearerTokenForAmApis","getUseBearerTokenForAmApis","setBearerToken","token","bearerToken","getBearerToken","setLogApiKey","key","logApiKey","getLogApiKey","FRODO_LOG_KEY","setLogApiSecret","secret","logApiSecret","getLogApiSecret","FRODO_LOG_SECRET","setAmVersion","version","amVersion","getAmVersion","setFrodoVersion","frodoVersion","getFrodoVersion","setConnectionProfilesPath","connectionProfilesPath","getConnectionProfilesPath","setMasterKeyPath","masterKeyPath","getMasterKeyPath","setOutputFile","file","outputFile","getOutputFile","setDirectory","directory","getDirectory","setPrintHandler","handler","getPrintHandler","setVerboseHandler","getVerboseHandler","setVerbose","verbose","setDebugHandler","getDebugHandler","setDebug","debug","FRODO_DEBUG","setCurlirizeHandler","getCurlirizeHandler","setCurlirize","curlirize","getCurlirize","setCreateProgressHandler","createProgressHandler","getCreateProgressHandler","setUpdateProgressHandler","updateProgressHandler","getUpdateProgressHandler","setStopProgressHandler","stopProgressHandler","getStopProgressHandler","session"],"sources":["shared/State.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { JwkRsa } from '../ops/JoseOps';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nexport interface StateInterface {\n // connection settings\n host?: string;\n username?: string;\n password?: string;\n realm?: string;\n deploymentType?: string;\n allowInsecureConnection?: boolean;\n // customize authentication\n authenticationHeaderOverrides?: Record<string, string>;\n authenticationService?: string;\n // cookie settings\n cookieName?: string;\n cookieValue?: string;\n // service account settings\n serviceAccountId?: string;\n serviceAccountJwk?: JwkRsa;\n // bearer token settings\n useBearerTokenForAmApis?: boolean;\n bearerToken?: string;\n // log api settings\n logApiKey?: string;\n logApiSecret?: string;\n // versions\n amVersion?: string;\n frodoVersion?: string;\n // miscellaneous settings\n connectionProfilesPath?: string;\n masterKeyPath?: string;\n outputFile?: string;\n directory?: string;\n // output handler settings\n printHandler?: (\n message: string | object,\n type?: string,\n newline?: boolean\n ) => void;\n verboseHandler?: (message: string | object) => void;\n verbose?: boolean;\n debugHandler?: (message: string | object) => void;\n debug?: boolean;\n curlirizeHandler?: (message: string) => void;\n curlirize?: boolean;\n createProgressHandler?: (\n type: string,\n total?: number,\n message?: string\n ) => void;\n updateProgressHandler?: (message: string) => void;\n stopProgressHandler?: (message: string, status?: string) => void;\n}\n\nconst _state: StateInterface = {\n authenticationHeaderOverrides: {},\n printHandler: (message: string | object) => {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else {\n console.log(message);\n }\n },\n verboseHandler: (message: string | object) => {\n if (!message) return;\n if (getVerbose()) {\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else {\n console.log(message);\n }\n }\n },\n debugHandler: (message: string | object) => {\n if (!message) return;\n if (getDebug()) {\n if (typeof message === 'object') {\n console.dir(message, { depth: 6 });\n } else {\n console.log(message);\n }\n }\n },\n curlirizeHandler: (message: string) => {\n if (!message) return;\n if (getDebug()) {\n console.log(message);\n }\n },\n};\n\nexport const setHost = (host: string) => (_state.host = host);\nexport const getHost = () => _state.host || process.env.FRODO_HOST;\n\n/**\n * @deprecated since v0.17.0 use `setHost(host: string)` instead\n */\nexport const setTenant = setHost;\n/**\n * @deprecated since v0.17.0 use `getHost` instead\n */\nexport const getTenant = getHost;\n\nexport const setUsername = (username: string) => (_state.username = username);\nexport const getUsername = () => _state.username || process.env.FRODO_USERNAME;\n\nexport const setPassword = (password: string) => (_state.password = password);\nexport const getPassword = () => _state.password || process.env.FRODO_PASSWORD;\n\nexport const setRealm = (realm: string) => (_state.realm = realm);\nexport const getRealm = () => _state.realm || process.env.FRODO_REALM;\n\nexport const setDeploymentType = (type: string) =>\n (_state.deploymentType = type);\nexport const getDeploymentType = () => _state.deploymentType;\n\nexport const setAllowInsecureConnection = (allowInsecureConnection: boolean) =>\n (_state.allowInsecureConnection = allowInsecureConnection);\nexport const getAllowInsecureConnection = () =>\n _state['allowInsecureConnection'];\n\nexport const setCookieName = (name: string) => (_state.cookieName = name);\nexport const getCookieName = () => _state.cookieName;\nexport const setCookieValue = (value: string) => (_state.cookieValue = value);\nexport const getCookieValue = () => _state.cookieValue;\n\nexport const setAuthenticationHeaderOverrides = (\n overrides: Record<string, string>\n) => (_state.authenticationHeaderOverrides = overrides);\nexport const getAuthenticationHeaderOverrides = () =>\n _state.authenticationHeaderOverrides;\nexport const setAuthenticationService = (service: string) =>\n (_state.authenticationService = service);\nexport const getAuthenticationService = () => _state.authenticationService;\n\nexport const setServiceAccountId = (uuid: string) =>\n (_state.serviceAccountId = uuid);\nexport const getServiceAccountId = (): string =>\n _state.serviceAccountId || process.env.FRODO_SA_ID;\nexport const setServiceAccountJwk = (jwk: JwkRsa) =>\n (_state.serviceAccountJwk = { ...jwk });\nexport const getServiceAccountJwk = (): JwkRsa =>\n _state.serviceAccountJwk ||\n (process.env.FRODO_SA_JWK ? JSON.parse(process.env.FRODO_SA_JWK) : undefined);\n\nexport const setUseBearerTokenForAmApis = (useBearerTokenForAmApis: boolean) =>\n (_state.useBearerTokenForAmApis = useBearerTokenForAmApis);\nexport const getUseBearerTokenForAmApis = () => _state.useBearerTokenForAmApis;\nexport const setBearerToken = (token: string) => (_state.bearerToken = token);\nexport const getBearerToken = () => _state.bearerToken;\n\nexport const setLogApiKey = (key: string) => (_state.logApiKey = key);\nexport const getLogApiKey = () => _state.logApiKey || process.env.FRODO_LOG_KEY;\nexport const setLogApiSecret = (secret: string) =>\n (_state.logApiSecret = secret);\nexport const getLogApiSecret = () =>\n _state.logApiSecret || process.env.FRODO_LOG_SECRET;\n\nexport const setAmVersion = (version: string) => (_state.amVersion = version);\nexport const getAmVersion = () => _state.amVersion;\n\nexport const setFrodoVersion = (version: string) =>\n (_state.frodoVersion = version);\nexport const getFrodoVersion = () =>\n _state.frodoVersion || `v${pkg.version} [${process.version}]`;\n\nexport const setConnectionProfilesPath = (path: string) =>\n (_state.connectionProfilesPath = path);\nexport const getConnectionProfilesPath = () => _state.connectionProfilesPath;\n\nexport const setMasterKeyPath = (path: string) => (_state.masterKeyPath = path);\nexport const getMasterKeyPath = () => _state.masterKeyPath;\n\nexport const setOutputFile = (file: string) => (_state.outputFile = file);\nexport const getOutputFile = () => _state.outputFile;\n\nexport const setDirectory = (directory: string) =>\n (_state.directory = directory);\nexport const getDirectory = () => _state.directory;\n\nexport const setPrintHandler = (\n handler: (message: string | object, type?: string, newline?: boolean) => void\n) => (_state.printHandler = handler);\nexport const getPrintHandler = () => _state.printHandler;\n\nexport const setVerboseHandler = (\n handler: (message: string | object) => void\n) => (_state.verboseHandler = handler);\nexport const getVerboseHandler = () => _state.verboseHandler;\nexport const setVerbose = (verbose: boolean) => (_state.verbose = verbose);\nexport const getVerbose = (): boolean => _state.verbose;\n\nexport const setDebugHandler = (handler: (message: string | object) => void) =>\n (_state.debugHandler = handler);\nexport const getDebugHandler = () => _state.debugHandler;\nexport const setDebug = (debug: boolean) => (_state.debug = debug);\nexport const getDebug = (): boolean =>\n _state.debug || process.env.FRODO_DEBUG !== undefined;\n\nexport const setCurlirizeHandler = (handler: (message: string) => void) =>\n (_state.curlirizeHandler = handler);\nexport const getCurlirizeHandler = () => _state.curlirizeHandler;\nexport const setCurlirize = (curlirize: boolean) =>\n (_state.curlirize = curlirize);\nexport const getCurlirize = (): boolean => _state.curlirize;\n\nexport const setCreateProgressHandler = (\n handler: (type: string, total?: number, message?: string) => void\n) => (_state.createProgressHandler = handler);\nexport const getCreateProgressHandler = () => _state.createProgressHandler;\nexport const setUpdateProgressHandler = (handler: (message: string) => void) =>\n (_state.updateProgressHandler = handler);\nexport const getUpdateProgressHandler = () => _state.updateProgressHandler;\nexport const setStopProgressHandler = (\n handler: (message: string, status?: string) => void\n) => (_state.stopProgressHandler = handler);\nexport const getStopProgressHandler = () => _state.stopProgressHandler;\n\n/**\n * @deprecated since version v0.17.0. Import state:\n *\n * ```import { state } from '@rockcarver/frodo-lib';```\n *\n * then call functions:\n *\n * ```const username = state.getUsername();```\n */\nexport default {\n session: {\n setHost,\n getHost,\n\n setTenant,\n getTenant,\n\n setUsername,\n getUsername,\n\n setPassword,\n getPassword,\n\n setRealm,\n getRealm,\n\n setDeploymentType,\n getDeploymentType,\n\n setAllowInsecureConnection,\n getAllowInsecureConnection,\n\n setCookieName,\n getCookieName,\n setCookieValue,\n getCookieValue,\n\n setAuthenticationHeaderOverrides,\n getAuthenticationHeaderOverrides,\n setAuthenticationService,\n getAuthenticationService,\n\n setServiceAccountId,\n getServiceAccountId,\n setServiceAccountJwk,\n getServiceAccountJwk,\n\n setUseBearerTokenForAmApis,\n getUseBearerTokenForAmApis,\n setBearerToken,\n getBearerToken,\n\n setLogApiKey,\n getLogApiKey,\n setLogApiSecret,\n getLogApiSecret,\n\n setAmVersion,\n getAmVersion,\n\n setFrodoVersion,\n getFrodoVersion,\n\n setConnectionProfilesPath,\n getConnectionProfilesPath,\n\n setMasterKeyPath,\n getMasterKeyPath,\n\n setOutputFile,\n getOutputFile,\n\n setDirectory,\n getDirectory,\n\n setPrintHandler,\n getPrintHandler,\n\n setVerboseHandler,\n getVerboseHandler,\n setVerbose,\n getVerbose,\n\n setDebugHandler,\n getDebugHandler,\n setDebug,\n getDebug,\n\n setCurlirizeHandler,\n getCurlirizeHandler,\n setCurlirize,\n getCurlirize,\n\n setCreateProgressHandler,\n getCreateProgressHandler,\n setUpdateProgressHandler,\n getUpdateProgressHandler,\n setStopProgressHandler,\n getStopProgressHandler,\n },\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAoC;AAAA;AAAA;AAAA;AAGpC,IAAMA,QAAS,GAAGC,aAAI,CAACC,OAAO,CAAC,IAAAC,kBAAa,sDAAiB,CAAC;AAE9D,IAAMC,GAAG,GAAGC,IAAI,CAACC,KAAK,CACpBC,WAAE,CAACC,YAAY,CAACP,aAAI,CAACQ,OAAO,CAACT,QAAS,EAAE,oBAAoB,CAAC,EAAE,MAAM,CAAC,CACvE;AAsDD,IAAMU,MAAsB,GAAG;EAC7BC,6BAA6B,EAAE,CAAC,CAAC;EACjCC,YAAY,EAAGC,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"189750709",
4
2
  "identityResource": "managed/alpha_user",
5
3
  "uiConfig": {
6
4
  "categories": "[]"
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = autoSetupPolly;
6
+ exports.autoSetupPolly = autoSetupPolly;
7
+ exports.defaultMatchRequestsBy = defaultMatchRequestsBy;
7
8
  var _path = _interopRequireDefault(require("path"));
8
9
  var _url = require("url");
9
10
  var _setupPollyJest = _interopRequireDefault(require("setup-polly-jest"));
@@ -20,30 +21,58 @@ var {
20
21
  _core.Polly.register(_adapterNodeHttp.default);
21
22
  _core.Polly.register(_persisterFs.default);
22
23
  var _dirname = _path.default.dirname((0, _url.fileURLToPath)(require('url').pathToFileURL(__filename).toString()));
23
- _index.state.setHost('https://openam-frodo-dev.forgeblocks.com/am');
24
- _index.state.setRealm('alpha');
25
- var recordIfMissing = true;
24
+ var recordIfMissing = false;
26
25
  var mode = _utils.MODES.REPLAY;
27
26
 
28
27
  // resolve "/home/sandeepc/work/ForgeRock/sources/frodo-lib/esm/api" to
29
28
  // "/home/sandeepc/work/ForgeRock/sources/frodo-lib/src/test/recordings"
30
29
  var recordingsDir = _dirname.replace(/^(.*\/frodo-\w{3})(.*)$/gi, '$1/src/test/mock-recordings');
31
30
  switch (process.env.FRODO_POLLY_MODE) {
31
+ // record mock responses from a real env: `npm run test:record`
32
32
  case 'record':
33
+ {
34
+ _index.state.setHost(process.env.FRODO_HOST || 'https://openam-frodo-dev.forgeblocks.com/am');
35
+ _index.state.setRealm(process.env.FRODO_REALM || 'alpha');
36
+ if (!(await (0, _AuthenticateOps.getTokens)())) throw new Error("Unable to record mock responses from '".concat(_index.state.getHost(), "'"));
37
+ mode = _utils.MODES.RECORD;
38
+ recordIfMissing = true;
39
+ break;
40
+ }
41
+ // record mock responses from authentication APIs (don't authenticate): `npm run test:record_noauth`
42
+ case 'record_noauth':
33
43
  mode = _utils.MODES.RECORD;
34
- await (0, _AuthenticateOps.getTokens)();
35
- break;
36
- case 'replay':
37
- mode = _utils.MODES.REPLAY;
38
- _index.state.default.session.setCookieName('cookieName');
39
- _index.state.default.session.setCookieValue('cookieValue');
44
+ recordIfMissing = true;
40
45
  break;
41
- case 'offline':
42
- mode = _utils.MODES.REPLAY;
43
- recordIfMissing = false;
46
+ // replay mock responses: `npm test`
47
+ default:
48
+ _index.state.setHost(process.env.FRODO_HOST || 'https://openam-frodo-dev.forgeblocks.com/am');
49
+ _index.state.setRealm(process.env.FRODO_REALM || 'alpha');
50
+ _index.state.setCookieName('cookieName');
51
+ _index.state.setCookieValue('cookieValue');
44
52
  break;
45
53
  }
54
+ function defaultMatchRequestsBy() {
55
+ return JSON.parse(JSON.stringify({
56
+ method: true,
57
+ headers: false,
58
+ // do not match headers, because "Authorization" header is sent only at recording time
59
+ body: true,
60
+ order: false,
61
+ url: {
62
+ protocol: true,
63
+ username: false,
64
+ password: false,
65
+ hostname: false,
66
+ // we will record from different envs but run tests always against `frodo-dev`
67
+ port: false,
68
+ pathname: true,
69
+ query: true,
70
+ hash: true
71
+ }
72
+ }));
73
+ }
46
74
  function autoSetupPolly() {
75
+ var matchRequestsBy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMatchRequestsBy();
47
76
  return setupPolly({
48
77
  adapters: ['node-http'],
49
78
  mode,
@@ -57,23 +86,7 @@ function autoSetupPolly() {
57
86
  recordingsDir
58
87
  }
59
88
  },
60
- matchRequestsBy: {
61
- method: true,
62
- headers: false,
63
- // do not match headers, because "Authorization" header is sent only at recording time
64
- body: true,
65
- order: false,
66
- url: {
67
- protocol: true,
68
- username: false,
69
- password: false,
70
- hostname: true,
71
- port: false,
72
- pathname: true,
73
- query: true,
74
- hash: true
75
- }
76
- }
89
+ matchRequestsBy
77
90
  });
78
91
  }
79
92
  //# sourceMappingURL=AutoSetupPolly.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSetupPolly.js","names":["setupPolly","pollyJest","Polly","register","NodeHttpAdapter","FSPersister","__dirname","path","dirname","fileURLToPath","state","setHost","setRealm","recordIfMissing","mode","MODES","REPLAY","recordingsDir","replace","process","env","FRODO_POLLY_MODE","RECORD","getTokens","default","session","setCookieName","setCookieValue","autoSetupPolly","adapters","flushRequestsOnStop","logLevel","recordFailedRequests","persister","persisterOptions","fs","matchRequestsBy","method","headers","body","order","url","protocol","username","password","hostname","port","pathname","query","hash"],"sources":["utils/AutoSetupPolly.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport pollyJest from 'setup-polly-jest';\nimport { Polly } from '@pollyjs/core';\nimport { MODES } from '@pollyjs/utils';\nimport NodeHttpAdapter from '@pollyjs/adapter-node-http';\nimport FSPersister from '@pollyjs/persister-fs';\nimport { getTokens } from '../ops/AuthenticateOps';\nimport { state } from '../index';\n\nconst { setupPolly } = pollyJest;\nPolly.register(NodeHttpAdapter);\nPolly.register(FSPersister);\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nstate.setHost('https://openam-frodo-dev.forgeblocks.com/am');\nstate.setRealm('alpha');\n\nlet recordIfMissing = true;\nlet mode = MODES.REPLAY;\n\n// resolve \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/esm/api\" to\n// \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/src/test/recordings\"\nconst recordingsDir = __dirname.replace(\n /^(.*\\/frodo-\\w{3})(.*)$/gi,\n '$1/src/test/mock-recordings'\n);\n\nswitch (process.env.FRODO_POLLY_MODE) {\n case 'record':\n mode = MODES.RECORD;\n await getTokens();\n break;\n case 'replay':\n mode = MODES.REPLAY;\n state.default.session.setCookieName('cookieName');\n state.default.session.setCookieValue('cookieValue');\n break;\n case 'offline':\n mode = MODES.REPLAY;\n recordIfMissing = false;\n break;\n}\n\nexport default function autoSetupPolly() {\n return setupPolly({\n adapters: ['node-http'],\n mode,\n recordIfMissing,\n flushRequestsOnStop: true,\n logLevel: 'warn',\n recordFailedRequests: true,\n persister: 'fs',\n persisterOptions: {\n fs: {\n recordingsDir,\n },\n },\n matchRequestsBy: {\n method: true,\n headers: false, // do not match headers, because \"Authorization\" header is sent only at recording time\n body: true,\n order: false,\n url: {\n protocol: true,\n username: false,\n password: false,\n hostname: true,\n port: false,\n pathname: true,\n query: true,\n hash: true,\n },\n },\n });\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAiC;AAEjC,IAAM;EAAEA;AAAW,CAAC,GAAGC,uBAAS;AAChCC,WAAK,CAACC,QAAQ,CAACC,wBAAe,CAAC;AAC/BF,WAAK,CAACC,QAAQ,CAACE,oBAAW,CAAC;AAE3B,IAAMC,QAAS,GAAGC,aAAI,CAACC,OAAO,CAAC,IAAAC,kBAAa,sDAAiB,CAAC;AAE9DC,YAAK,CAACC,OAAO,CAAC,6CAA6C,CAAC;AAC5DD,YAAK,CAACE,QAAQ,CAAC,OAAO,CAAC;AAEvB,IAAIC,eAAe,GAAG,IAAI;AAC1B,IAAIC,IAAI,GAAGC,YAAK,CAACC,MAAM;;AAEvB;AACA;AACA,IAAMC,aAAa,GAAGX,QAAS,CAACY,OAAO,CACrC,2BAA2B,EAC3B,6BAA6B,CAC9B;AAED,QAAQC,OAAO,CAACC,GAAG,CAACC,gBAAgB;EAClC,KAAK,QAAQ;IACXP,IAAI,GAAGC,YAAK,CAACO,MAAM;IACnB,MAAM,IAAAC,0BAAS,GAAE;IACjB;EACF,KAAK,QAAQ;IACXT,IAAI,GAAGC,YAAK,CAACC,MAAM;IACnBN,YAAK,CAACc,OAAO,CAACC,OAAO,CAACC,aAAa,CAAC,YAAY,CAAC;IACjDhB,YAAK,CAACc,OAAO,CAACC,OAAO,CAACE,cAAc,CAAC,aAAa,CAAC;IACnD;EACF,KAAK,SAAS;IACZb,IAAI,GAAGC,YAAK,CAACC,MAAM;IACnBH,eAAe,GAAG,KAAK;IACvB;AAAM;AAGK,SAASe,cAAc,GAAG;EACvC,OAAO5B,UAAU,CAAC;IAChB6B,QAAQ,EAAE,CAAC,WAAW,CAAC;IACvBf,IAAI;IACJD,eAAe;IACfiB,mBAAmB,EAAE,IAAI;IACzBC,QAAQ,EAAE,MAAM;IAChBC,oBAAoB,EAAE,IAAI;IAC1BC,SAAS,EAAE,IAAI;IACfC,gBAAgB,EAAE;MAChBC,EAAE,EAAE;QACFlB;MACF;IACF,CAAC;IACDmB,eAAe,EAAE;MACfC,MAAM,EAAE,IAAI;MACZC,OAAO,EAAE,KAAK;MAAE;MAChBC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE,KAAK;MACZC,GAAG,EAAE;QACHC,QAAQ,EAAE,IAAI;QACdC,QAAQ,EAAE,KAAK;QACfC,QAAQ,EAAE,KAAK;QACfC,QAAQ,EAAE,IAAI;QACdC,IAAI,EAAE,KAAK;QACXC,QAAQ,EAAE,IAAI;QACdC,KAAK,EAAE,IAAI;QACXC,IAAI,EAAE;MACR;IACF;EACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"AutoSetupPolly.js","names":["setupPolly","pollyJest","Polly","register","NodeHttpAdapter","FSPersister","__dirname","path","dirname","fileURLToPath","recordIfMissing","mode","MODES","REPLAY","recordingsDir","replace","process","env","FRODO_POLLY_MODE","state","setHost","FRODO_HOST","setRealm","FRODO_REALM","getTokens","Error","getHost","RECORD","setCookieName","setCookieValue","defaultMatchRequestsBy","JSON","parse","stringify","method","headers","body","order","url","protocol","username","password","hostname","port","pathname","query","hash","autoSetupPolly","matchRequestsBy","adapters","flushRequestsOnStop","logLevel","recordFailedRequests","persister","persisterOptions","fs"],"sources":["utils/AutoSetupPolly.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport pollyJest from 'setup-polly-jest';\nimport { Polly } from '@pollyjs/core';\nimport { MODES } from '@pollyjs/utils';\nimport NodeHttpAdapter from '@pollyjs/adapter-node-http';\nimport FSPersister from '@pollyjs/persister-fs';\nimport { getTokens } from '../ops/AuthenticateOps';\nimport { state } from '../index';\n\nconst { setupPolly } = pollyJest;\nPolly.register(NodeHttpAdapter);\nPolly.register(FSPersister);\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nlet recordIfMissing = false;\nlet mode = MODES.REPLAY;\n\n// resolve \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/esm/api\" to\n// \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/src/test/recordings\"\nconst recordingsDir = __dirname.replace(\n /^(.*\\/frodo-\\w{3})(.*)$/gi,\n '$1/src/test/mock-recordings'\n);\n\nswitch (process.env.FRODO_POLLY_MODE) {\n // record mock responses from a real env: `npm run test:record`\n case 'record': {\n state.setHost(\n process.env.FRODO_HOST || 'https://openam-frodo-dev.forgeblocks.com/am'\n );\n state.setRealm(process.env.FRODO_REALM || 'alpha');\n if (!(await getTokens()))\n throw new Error(\n `Unable to record mock responses from '${state.getHost()}'`\n );\n mode = MODES.RECORD;\n recordIfMissing = true;\n break;\n }\n // record mock responses from authentication APIs (don't authenticate): `npm run test:record_noauth`\n case 'record_noauth':\n mode = MODES.RECORD;\n recordIfMissing = true;\n break;\n // replay mock responses: `npm test`\n default:\n state.setHost(\n process.env.FRODO_HOST || 'https://openam-frodo-dev.forgeblocks.com/am'\n );\n state.setRealm(process.env.FRODO_REALM || 'alpha');\n state.setCookieName('cookieName');\n state.setCookieValue('cookieValue');\n break;\n}\n\nexport function defaultMatchRequestsBy() {\n return JSON.parse(\n JSON.stringify({\n method: true,\n headers: false, // do not match headers, because \"Authorization\" header is sent only at recording time\n body: true,\n order: false,\n url: {\n protocol: true,\n username: false,\n password: false,\n hostname: false, // we will record from different envs but run tests always against `frodo-dev`\n port: false,\n pathname: true,\n query: true,\n hash: true,\n },\n })\n );\n}\n\nexport function autoSetupPolly(matchRequestsBy = defaultMatchRequestsBy()) {\n return setupPolly({\n adapters: ['node-http'],\n mode,\n recordIfMissing,\n flushRequestsOnStop: true,\n logLevel: 'warn',\n recordFailedRequests: true,\n persister: 'fs',\n persisterOptions: {\n fs: {\n recordingsDir,\n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K,CAACU,cAAc,CAAC,aAAa,CAAC;IACnC;AAAM;AAGH,SAASC,sBAAsB,GAAG;EACvC,OAAOC,IAAI,CAACC,KAAK,CACfD,IAAI,CAACE,SAAS,CAAC;IACbC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE,KAAK;IAAE;IAChBC,IAAI,EAAE,IAAI;IACVC,KAAK,EAAE,KAAK;IACZC,GAAG,EAAE;MACHC,QAAQ,EAAE,IAAI;MACdC,QAAQ,EAAE,KAAK;MACfC,QAAQ,EAAE,KAAK;MACfC,QAAQ,EAAE,KAAK;MAAE;MACjBC,IAAI,EAAE,KAAK;MACXC,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE,IAAI;MACXC,IAAI,EAAE;IACR;EACF,CAAC,CAAC,CACH;AACH;AAEO,SAASC,cAAc,GAA6C;EAAA,IAA5CC,eAAe,uEAAGlB,sBAAsB,EAAE;EACvE,OAAO9B,UAAU,CAAC;IAChBiD,QAAQ,EAAE,CAAC,WAAW,CAAC;IACvBtC,IAAI;IACJD,eAAe;IACfwC,mBAAmB,EAAE,IAAI;IACzBC,QAAQ,EAAE,MAAM;IAChBC,oBAAoB,EAAE,IAAI;IAC1BC,SAAS,EAAE,IAAI;IACfC,gBAAgB,EAAE;MAChBC,EAAE,EAAE;QACFzC;MACF;IACF,CAAC;IACDkC;EACF,CAAC,CAAC;AACJ"}
@@ -1,150 +1,253 @@
1
- import axios from 'axios';
2
- import MockAdapter from 'axios-mock-adapter';
3
- import { TreeRaw, state } from '../index';
4
- import fs from 'fs';
5
- import path from 'path';
6
- import { fileURLToPath } from 'url';
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const mock = new MockAdapter(axios);
9
- state.setHost('');
10
- state.setRealm('alpha');
11
- state.setCookieName('cookieName');
12
- state.setCookieValue('cookieValue');
13
- describe('TreeApi - getTrees()', () => {
14
- test('getTrees() 0: Method is implemented', async () => {
15
- expect(TreeRaw.getTrees).toBeDefined();
16
- });
17
- test('getTrees() 1: Get all trees', async () => {
18
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/getTrees/trees.json'), 'utf8'));
19
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees?_queryFilter=true`).reply(200, response);
20
- const trees = await TreeRaw.getTrees();
21
- expect(trees).toBeTruthy();
22
- expect(trees).toMatchSnapshot();
23
- });
24
- });
25
- describe('TreeApi - getTree()', () => {
26
- test('getTree() 0: Method is implemented', async () => {
27
- expect(TreeRaw.getTree).toBeDefined();
28
- });
29
- test('getTree() 1: Get existing tree', async () => {
30
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/getTree/FrodoTest.json'), 'utf8'));
31
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/FrodoTest`).reply(200, response);
32
- const tree = await TreeRaw.getTree('FrodoTest');
33
- expect(tree).toBeTruthy();
34
- expect(tree).toMatchSnapshot();
35
- });
36
- test('getTree() 2: Get non-existing tree', async () => {
37
- mock.onGet(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/DoesNotExist`).reply(404, {
38
- code: 404,
39
- reason: 'Not Found',
40
- message: 'Not Found'
1
+ /**
2
+ * To record and update snapshots, you must perform 3 steps in order:
3
+ *
4
+ * 1. Record API responses & update ESM snapshots
5
+ *
6
+ * To record and update ESM snapshots, you must call the test:record
7
+ * script and override all the connection state variables required
8
+ * to connect to the env to record from:
9
+ *
10
+ * FRODO_DEBUG=1 FRODO_HOST=volker-dev npm run test:record TreeApi
11
+ *
12
+ * The above command assumes that you have a connection profile for
13
+ * 'volker-dev' on your development machine.
14
+ *
15
+ * 2. Update CJS snapshots
16
+ *
17
+ * After recording, the ESM snapshots will already be updated as that happens
18
+ * in one go, but you musty manually update the CJS snapshots by running:
19
+ *
20
+ * FRODO_DEBUG=1 npm run test:update TreeApi
21
+ *
22
+ * 3. Test your changes
23
+ *
24
+ * If 1 and 2 didn't produce any errors, you are ready to run the tests in
25
+ * replay mode and make sure they all succeed as well:
26
+ *
27
+ * npm run test TreeApi
28
+ *
29
+ * Note: FRODO_DEBUG=1 is optional and enables debug logging for some output
30
+ * in case things don't function as expected
31
+ */
32
+ import { TreeRaw } from '../index';
33
+ import { autoSetupPolly } from '../utils/AutoSetupPolly';
34
+ autoSetupPolly();
35
+ describe('TreeApi', () => {
36
+ describe('getTrees()', () => {
37
+ test('0: Method is implemented', async () => {
38
+ expect(TreeRaw.getTrees).toBeDefined();
41
39
  });
42
- try {
43
- await TreeRaw.getTree('DoesNotExist');
44
- } catch (error) {
45
- expect(error.response.data).toMatchSnapshot();
46
- }
47
- });
48
- });
49
- describe('TreeApi - putTree()', () => {
50
- test('putTree() 0: Method is implemented', async () => {
51
- expect(TreeRaw.putTree).toBeDefined();
52
- });
53
- test('putTree() 1: Put valid tree', async () => {
54
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/putTree/FrodoTest.json'), 'utf8'));
55
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/FrodoTest`).reply(201, response);
56
- const tree = await TreeRaw.putTree('FrodoTest', response);
57
- expect(tree).toBeTruthy();
58
- expect(tree).toMatchSnapshot();
59
- });
60
- test('putTree() 2: Put invalid tree [trailing data]', async () => {
61
- const request = fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/putTree/Invalid_trailing-data.txt'), 'utf8');
62
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/Invalid`).reply(400, {
63
- code: 400,
64
- reason: 'Bad Request',
65
- message: 'The request could not be processed because there is trailing data after the JSON content'
40
+ test('1: Get all trees', async () => {
41
+ const response = await TreeRaw.getTrees();
42
+ expect(response).toMatchSnapshot();
66
43
  });
67
- expect.assertions(2);
68
- try {
69
- await TreeRaw.putTree('Invalid', request);
70
- } catch (error) {
71
- expect(error.response).toBeTruthy();
72
- expect(error.response.data).toMatchSnapshot();
73
- }
74
44
  });
75
- test('putTree() 3: Put invalid tree [invalid attribute]', async () => {
76
- const request = fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/putTree/Invalid_invalid-attribute.json'), 'utf8');
77
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/Invalid`).reply(400, {
78
- code: 400,
79
- reason: 'Bad Request',
80
- message: 'Invalid attribute specified.',
81
- detail: {
82
- validAttributes: ['description', 'enabled', 'entryNodeId', 'identityResource', 'nodes', 'staticNodes', 'uiConfig']
45
+ describe('getTree()', () => {
46
+ test('0: Method is implemented', async () => {
47
+ expect(TreeRaw.getTree).toBeDefined();
48
+ });
49
+ test('1: Get existing tree', async () => {
50
+ const response = await TreeRaw.getTree('FrodoTest');
51
+ expect(response).toMatchSnapshot();
52
+ });
53
+ test('2: Get non-existing tree', async () => {
54
+ try {
55
+ await TreeRaw.getTree('DoesNotExist');
56
+ } catch (error) {
57
+ expect(error.response.data).toMatchSnapshot();
83
58
  }
84
59
  });
85
- expect.assertions(2);
86
- try {
87
- await TreeRaw.putTree('Invalid', request);
88
- } catch (error) {
89
- expect(error.response).toBeTruthy();
90
- expect(error.response.data).toMatchSnapshot();
91
- }
92
60
  });
93
- test('putTree() 4: Put invalid tree [no entry node]', async () => {
94
- const request = fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/putTree/Invalid_no-entry-node.json'), 'utf8');
95
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/Invalid`).reply(400, {
96
- code: 400,
97
- reason: 'Bad Request',
98
- message: 'Node with ID entryNodeId must exist in the tree.'
61
+ describe('putTree()', () => {
62
+ test('0: Method is implemented', async () => {
63
+ expect(TreeRaw.putTree).toBeDefined();
99
64
  });
100
- expect.assertions(2);
101
- try {
102
- await TreeRaw.putTree('Invalid', request);
103
- } catch (error) {
104
- expect(error.response).toBeTruthy();
105
- expect(error.response.data).toMatchSnapshot();
106
- }
107
- });
108
- test('putTree() 5: Put invalid tree [invalid nodes]', async () => {
109
- const request = fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/putTree/Invalid_invalid-nodes.json'), 'utf8');
110
- mock.onPut(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/Invalid`).reply(400, {
111
- code: 400,
112
- reason: 'Bad Request',
113
- message: 'Node with ID entryNodeId must exist in the tree.'
65
+ test('1: Put valid tree', async () => {
66
+ const treeData = JSON.parse(JSON.stringify({
67
+ identityResource: 'managed/alpha_user',
68
+ uiConfig: {
69
+ categories: '[]'
70
+ },
71
+ entryNodeId: 'e2c39477-847a-4df2-9c5d-b449a752638b',
72
+ nodes: {
73
+ '278bf084-9eea-46fe-8ce9-2600dde3b046': {
74
+ connections: {
75
+ localAuthentication: 'fc7e47cd-c679-4211-8e05-a36654f23c67',
76
+ socialAuthentication: 'd5cc2d52-6ce4-452d-85ea-3a5b50218b67'
77
+ },
78
+ displayName: 'Login Page',
79
+ nodeType: 'PageNode',
80
+ x: 444,
81
+ y: 273.015625
82
+ },
83
+ '64157fca-bd5b-4405-a4c8-64ffd98a5461': {
84
+ connections: {
85
+ ACCOUNT_EXISTS: '70e691a5-1e33-4ac3-a356-e7b6d60d92e0',
86
+ NO_ACCOUNT: 'e301438c-0bd0-429c-ab0c-66126501069a'
87
+ },
88
+ displayName: 'SAML2 Authentication',
89
+ nodeType: 'product-Saml2Node',
90
+ x: 1168,
91
+ y: 188.015625
92
+ },
93
+ '731c5810-020b-45c8-a7fc-3c21903ae2b3': {
94
+ connections: {
95
+ localAuthentication: 'fc7e47cd-c679-4211-8e05-a36654f23c67',
96
+ socialAuthentication: 'd5cc2d52-6ce4-452d-85ea-3a5b50218b67'
97
+ },
98
+ displayName: 'Login Page',
99
+ nodeType: 'PageNode',
100
+ x: 443,
101
+ y: 26.015625
102
+ },
103
+ 'bf153f37-83dd-4f39-aa0c-74135430242e': {
104
+ connections: {
105
+ EMAIL_NOT_SENT: 'e301438c-0bd0-429c-ab0c-66126501069a',
106
+ EMAIL_SENT: '64157fca-bd5b-4405-a4c8-64ffd98a5461'
107
+ },
108
+ displayName: 'Email Template Node',
109
+ nodeType: 'EmailTemplateNode',
110
+ x: 910,
111
+ y: 224.015625
112
+ },
113
+ 'd5cc2d52-6ce4-452d-85ea-3a5b50218b67': {
114
+ connections: {
115
+ ACCOUNT_EXISTS: '70e691a5-1e33-4ac3-a356-e7b6d60d92e0',
116
+ NO_ACCOUNT: 'bf153f37-83dd-4f39-aa0c-74135430242e'
117
+ },
118
+ displayName: 'Social Login',
119
+ nodeType: 'SocialProviderHandlerNode',
120
+ x: 702,
121
+ y: 116.015625
122
+ },
123
+ 'e2c39477-847a-4df2-9c5d-b449a752638b': {
124
+ connections: {
125
+ known: '731c5810-020b-45c8-a7fc-3c21903ae2b3',
126
+ unknown: '278bf084-9eea-46fe-8ce9-2600dde3b046'
127
+ },
128
+ displayName: 'Check Username',
129
+ nodeType: 'ScriptedDecisionNode',
130
+ x: 200,
131
+ y: 235.015625
132
+ },
133
+ 'fc7e47cd-c679-4211-8e05-a36654f23c67': {
134
+ connections: {
135
+ CANCELLED: '70e691a5-1e33-4ac3-a356-e7b6d60d92e0',
136
+ EXPIRED: '70e691a5-1e33-4ac3-a356-e7b6d60d92e0',
137
+ FALSE: 'e301438c-0bd0-429c-ab0c-66126501069a',
138
+ LOCKED: 'e301438c-0bd0-429c-ab0c-66126501069a',
139
+ TRUE: '70e691a5-1e33-4ac3-a356-e7b6d60d92e0'
140
+ },
141
+ displayName: 'Validate Creds',
142
+ nodeType: 'IdentityStoreDecisionNode',
143
+ x: 702,
144
+ y: 292.015625
145
+ }
146
+ },
147
+ staticNodes: {
148
+ '70e691a5-1e33-4ac3-a356-e7b6d60d92e0': {
149
+ x: 1434,
150
+ y: 60
151
+ },
152
+ 'e301438c-0bd0-429c-ab0c-66126501069a': {
153
+ x: 1433,
154
+ y: 459
155
+ },
156
+ startNode: {
157
+ x: 63,
158
+ y: 252
159
+ }
160
+ },
161
+ enabled: true
162
+ }));
163
+ const response = await TreeRaw.putTree('FrodoTest', treeData);
164
+ expect(response).toMatchSnapshot();
165
+ });
166
+ test('2: Put invalid tree [trailing data]', async () => {
167
+ const treeData = JSON.stringify({
168
+ entryNodeId: 'e301438c-0bd0-429c-ab0c-66126501069a',
169
+ nodes: {},
170
+ staticNodes: {},
171
+ description: 'invalid tree def',
172
+ identityResource: 'managed/alpha_user',
173
+ uiConfig: {
174
+ categories: '[]'
175
+ }
176
+ }) + '\ntrailing data';
177
+ try {
178
+ await TreeRaw.putTree('Invalid', treeData);
179
+ } catch (error) {
180
+ expect(error.response.data).toMatchSnapshot();
181
+ }
182
+ });
183
+ test('3: Put invalid tree [invalid attribute]', async () => {
184
+ const treeData = JSON.parse(JSON.stringify({
185
+ entryNodeId: 'e301438c-0bd0-429c-ab0c-66126501069a',
186
+ nodes2: {},
187
+ staticNodes: {},
188
+ description: 'invalid tree def',
189
+ identityResource: 'managed/alpha_user',
190
+ uiConfig: {
191
+ categories: '[]'
192
+ }
193
+ }));
194
+ try {
195
+ await TreeRaw.putTree('Invalid', treeData);
196
+ } catch (error) {
197
+ expect(error.response.data).toMatchSnapshot();
198
+ }
199
+ });
200
+ test('4: Put invalid tree [no entry node]', async () => {
201
+ const treeData = JSON.parse(JSON.stringify({
202
+ nodes: {},
203
+ staticNodes: {},
204
+ description: 'invalid tree def',
205
+ identityResource: 'managed/alpha_user',
206
+ uiConfig: {
207
+ categories: '[]'
208
+ }
209
+ }));
210
+ try {
211
+ await TreeRaw.putTree('Invalid', treeData);
212
+ } catch (error) {
213
+ expect(error.response.data).toMatchSnapshot();
214
+ }
215
+ });
216
+ test('5: Put invalid tree [invalid nodes]', async () => {
217
+ const treeData = JSON.parse(JSON.stringify({
218
+ entryNodeId: 'e301438c-0bd0-429c-ab0c-66126501069a',
219
+ nodes: {
220
+ invalid: 'bad data'
221
+ },
222
+ staticNodes: {},
223
+ description: 'invalid tree def',
224
+ identityResource: 'managed/alpha_user',
225
+ uiConfig: {
226
+ categories: '[]'
227
+ }
228
+ }));
229
+ try {
230
+ await TreeRaw.putTree('Invalid', treeData);
231
+ } catch (error) {
232
+ expect(error.response.data).toMatchSnapshot();
233
+ }
114
234
  });
115
- expect.assertions(2);
116
- try {
117
- await TreeRaw.putTree('Invalid', request);
118
- } catch (error) {
119
- expect(error.response).toBeTruthy();
120
- expect(error.response.data).toMatchSnapshot();
121
- }
122
- });
123
- });
124
- describe('TreeApi - deleteTree()', () => {
125
- test('deleteTree() 0: Method is implemented', async () => {
126
- expect(TreeRaw.deleteTree).toBeDefined();
127
- });
128
- test('deleteTree() 1: Delete existing tree', async () => {
129
- const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/mocks/TreeApi/deleteTree/FrodoTest.json'), 'utf8'));
130
- mock.onDelete(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/FrodoTest`).reply(200, response);
131
- const tree = await TreeRaw.deleteTree('FrodoTest');
132
- expect(tree).toBeTruthy();
133
- expect(tree).toMatchSnapshot();
134
235
  });
135
- test('deleteTree() 2: Delete non-existing tree', async () => {
136
- mock.onDelete(`${state.getHost()}/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/trees/DoesNotExist`).reply(404, {
137
- code: 404,
138
- reason: 'Not Found',
139
- message: 'Not Found'
236
+ describe('deleteTree()', () => {
237
+ test('0: Method is implemented', async () => {
238
+ expect(TreeRaw.deleteTree).toBeDefined();
239
+ });
240
+ test('1: Delete existing tree', async () => {
241
+ const response = await TreeRaw.deleteTree('FrodoTest');
242
+ expect(response).toMatchSnapshot();
243
+ });
244
+ test('2: Delete non-existing tree', async () => {
245
+ try {
246
+ await TreeRaw.deleteTree('DoesNotExist');
247
+ } catch (error) {
248
+ expect(error.response.data).toMatchSnapshot();
249
+ }
140
250
  });
141
- expect.assertions(2);
142
- try {
143
- await TreeRaw.deleteTree('DoesNotExist');
144
- } catch (error) {
145
- expect(error.response).toBeTruthy();
146
- expect(error.response.data).toMatchSnapshot();
147
- }
148
251
  });
149
252
  });
150
253
  //# sourceMappingURL=TreeApi.test.js.map