mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 14:44:07 +00:00
Merge pull request #5376 from lohit-bruno/oauth2_additional_parameters
Oauth2 additional parameters updates
This commit is contained in:
@@ -19,6 +19,27 @@ const StyledWrapper = styled.div`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-weight: 600;
|
||||
table-layout: fixed;
|
||||
|
||||
thead,
|
||||
td {
|
||||
border: 1px solid ${(props) => props.theme.table.border};
|
||||
}
|
||||
|
||||
thead {
|
||||
color: ${(props) => props.theme.table.thead.color};
|
||||
font-size: 0.8125rem;
|
||||
user-select: none;
|
||||
}
|
||||
td {
|
||||
padding: 6px 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.additional-parameter-sends-in-selector {
|
||||
select {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { useDispatch } from "react-redux";
|
||||
import React, { forwardRef, useState } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import get from 'lodash/get';
|
||||
import { useTheme } from 'providers/Theme';
|
||||
import { IconPlus, IconCaretDown, IconTrash, IconAdjustmentsHorizontal } from '@tabler/icons';
|
||||
import { IconPlus, IconTrash, IconAdjustmentsHorizontal } from '@tabler/icons';
|
||||
import { cloneDeep } from "lodash";
|
||||
import SingleLineEditor from "components/SingleLineEditor/index";
|
||||
import StyledWrapper from "./StyledWrapper";
|
||||
import Table from "components/Table/index";
|
||||
|
||||
const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => {
|
||||
const AdditionalParams = ({ item = {}, request, updateAuth, collection, handleSave }) => {
|
||||
const dispatch = useDispatch();
|
||||
const { storedTheme } = useTheme();
|
||||
|
||||
@@ -201,6 +201,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => {
|
||||
value
|
||||
})}
|
||||
collection={collection}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
@@ -214,6 +215,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => {
|
||||
value
|
||||
})}
|
||||
collection={collection}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
@@ -272,7 +274,7 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => {
|
||||
</tbody>
|
||||
</Table>
|
||||
<div
|
||||
className={`add-additional-param-actions flex items-center mt-2 ${addButtonDisabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
|
||||
className={`add-additional-param-actions w-fit flex items-center mt-2 ${addButtonDisabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
|
||||
onClick={addButtonDisabled ? null : handleAddNewAdditionalParam}
|
||||
>
|
||||
<IconPlus size={16} strokeWidth={1.5} style={{ marginLeft: '2px' }} />
|
||||
@@ -284,20 +286,6 @@ const AdditionalParams = ({ item = {}, request, updateAuth, collection }) => {
|
||||
|
||||
export default AdditionalParams;
|
||||
|
||||
const Icon = forwardRef((props, ref) => {
|
||||
const { value } = props
|
||||
return (
|
||||
<div ref={ref} className="w-max textbox border p-2 rounded cursor-pointer flex items-center selector-label">
|
||||
<div className="flex-grow font-medium">
|
||||
{value}
|
||||
</div>
|
||||
<div>
|
||||
<IconCaretDown className="caret mx-2" size={14} strokeWidth={2} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
const sendInOptionsMap = {
|
||||
'authorization_code': {
|
||||
'authorization': ['headers', 'queryparams'],
|
||||
|
||||
@@ -336,11 +336,12 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
handleSave={handleSave}
|
||||
/>
|
||||
<Oauth2ActionButtons item={item} request={request} collection={collection} url={accessTokenUrl} credentialsId={credentialsId} />
|
||||
</StyledWrapper>
|
||||
|
||||
@@ -293,11 +293,12 @@ const OAuth2ClientCredentials = ({ save, item = {}, request, handleRun, updateAu
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
handleSave={handleSave}
|
||||
/>
|
||||
<Oauth2ActionButtons item={item} request={request} collection={collection} url={accessTokenUrl} credentialsId={credentialsId} />
|
||||
|
||||
|
||||
@@ -218,11 +218,12 @@ const OAuth2Implicit = ({ save, item = {}, request, handleRun, updateAuth, colle
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
handleSave={handleSave}
|
||||
/>
|
||||
<Oauth2ActionButtons item={item} request={request} collection={collection} url={interpolatedAuthUrl} credentialsId={credentialsId} />
|
||||
</Wrapper>
|
||||
|
||||
@@ -296,11 +296,12 @@ const OAuth2PasswordCredentials = ({ save, item = {}, request, handleRun, update
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
<AdditionalParams
|
||||
item={item}
|
||||
request={request}
|
||||
collection={collection}
|
||||
updateAuth={updateAuth}
|
||||
handleSave={handleSave}
|
||||
/>
|
||||
<Oauth2ActionButtons item={item} request={request} collection={collection} url={accessTokenUrl} credentialsId={credentialsId} />
|
||||
</StyledWrapper>
|
||||
|
||||
@@ -1324,7 +1324,7 @@ export const refreshOauth2Credentials = (payload) => async (dispatch, getState)
|
||||
request.globalEnvironmentVariables = globalEnvironmentVariables;
|
||||
return new Promise((resolve, reject) => {
|
||||
window.ipcRenderer
|
||||
.invoke('renderer:refresh-oauth2-credentials', { request, collection })
|
||||
.invoke('renderer:refresh-oauth2-credentials', { itemUid, request, collection })
|
||||
.then(({ credentials, url, collectionUid, debugInfo, credentialsId }) => {
|
||||
dispatch(
|
||||
collectionAddOauth2CredentialsByUrl({
|
||||
|
||||
@@ -985,9 +985,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
const processEnvVars = getProcessEnvVars(collectionUid);
|
||||
const partialItem = { uid: itemUid };
|
||||
const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem);
|
||||
if (requestTreePath && requestTreePath.length > 0) {
|
||||
mergeVars(collection, requestCopy, requestTreePath);
|
||||
}
|
||||
mergeVars(collection, requestCopy, requestTreePath);
|
||||
|
||||
interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars);
|
||||
const certsAndProxyConfig = await getCertsAndProxyConfig({
|
||||
@@ -1108,7 +1106,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { request, collection }) => {
|
||||
ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { itemUid, request, collection }) => {
|
||||
try {
|
||||
if (request.oauth2) {
|
||||
let requestCopy = _.cloneDeep(request);
|
||||
@@ -1116,7 +1114,11 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
const environment = _.find(environments, (e) => e.uid === activeEnvironmentUid);
|
||||
const envVars = getEnvVars(environment);
|
||||
const processEnvVars = getProcessEnvVars(collectionUid);
|
||||
const partialItem = { uid: itemUid };
|
||||
const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem);
|
||||
mergeVars(collection, requestCopy, requestTreePath);
|
||||
interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars);
|
||||
|
||||
const certsAndProxyConfig = await getCertsAndProxyConfig({
|
||||
collectionUid,
|
||||
request: requestCopy,
|
||||
|
||||
@@ -47,7 +47,7 @@ const mergeHeaders = (collection, request, requestTreePath) => {
|
||||
request.headers = Array.from(headers, ([name, value]) => ({ name, value, enabled: true }));
|
||||
};
|
||||
|
||||
const mergeVars = (collection, request, requestTreePath) => {
|
||||
const mergeVars = (collection, request, requestTreePath = []) => {
|
||||
let reqVars = new Map();
|
||||
let collectionRequestVars = get(collection, 'root.request.vars.req', []);
|
||||
let collectionVariables = {};
|
||||
|
||||
@@ -13,7 +13,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"grantType": grantType,
|
||||
},
|
||||
},
|
||||
"oauth2_additional_parameters_authorization_headers": [
|
||||
"oauth2_additional_parameters_auth_req_headers": [
|
||||
{
|
||||
"name": "auth-header",
|
||||
"value": "auth-header-value",
|
||||
@@ -25,7 +25,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_authorization_queryparams": [
|
||||
"oauth2_additional_parameters_auth_req_queryparams": [
|
||||
{
|
||||
"name": "auth-query-param",
|
||||
"value": "auth-query-param-value",
|
||||
@@ -37,7 +37,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_token_headers": [
|
||||
"oauth2_additional_parameters_access_token_req_headers": [
|
||||
{
|
||||
"name": "token-header",
|
||||
"value": "token-header-value",
|
||||
@@ -49,7 +49,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_token_queryparams": [
|
||||
"oauth2_additional_parameters_access_token_req_queryparams": [
|
||||
{
|
||||
"name": "token-query-param",
|
||||
"value": "token-query-param-value",
|
||||
@@ -61,7 +61,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_token_bodyvalues": [
|
||||
"oauth2_additional_parameters_access_token_req_bodyvalues": [
|
||||
{
|
||||
"name": "token-body",
|
||||
"value": "token-body-value",
|
||||
@@ -73,7 +73,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_refresh_headers": [
|
||||
"oauth2_additional_parameters_refresh_token_req_headers": [
|
||||
{
|
||||
"name": "refresh-header",
|
||||
"value": "refresh-header-value",
|
||||
@@ -85,7 +85,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_refresh_queryparams": [
|
||||
"oauth2_additional_parameters_refresh_token_req_queryparams": [
|
||||
{
|
||||
"name": "refresh-query-param",
|
||||
"value": "refresh-query-param-value",
|
||||
@@ -97,7 +97,7 @@ const getBruJsonWithAdditionalParams = (grantType) => ({
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"oauth2_additional_parameters_refresh_bodyvalues": [
|
||||
"oauth2_additional_parameters_refresh_token_req_bodyvalues": [
|
||||
{
|
||||
"name": "refresh-body",
|
||||
"value": "refresh-body-value",
|
||||
|
||||
@@ -23,14 +23,14 @@ export interface T_BruJson {
|
||||
auth: {
|
||||
oauth2: T_Oauth2Auth;
|
||||
};
|
||||
oauth2_additional_parameters_authorization_headers?: any[];
|
||||
oauth2_additional_parameters_authorization_queryparams?: any[];
|
||||
oauth2_additional_parameters_token_headers?: any[];
|
||||
oauth2_additional_parameters_token_queryparams?: any[];
|
||||
oauth2_additional_parameters_token_bodyvalues?: any[];
|
||||
oauth2_additional_parameters_refresh_headers?: any[];
|
||||
oauth2_additional_parameters_refresh_queryparams?: any[];
|
||||
oauth2_additional_parameters_refresh_bodyvalues?: any[];
|
||||
oauth2_additional_parameters_auth_req_headers?: any[];
|
||||
oauth2_additional_parameters_auth_req_queryparams?: any[];
|
||||
oauth2_additional_parameters_access_token_req_headers?: any[];
|
||||
oauth2_additional_parameters_access_token_req_queryparams?: any[];
|
||||
oauth2_additional_parameters_access_token_req_bodyvalues?: any[];
|
||||
oauth2_additional_parameters_refresh_token_req_headers?: any[];
|
||||
oauth2_additional_parameters_refresh_token_req_queryparams?: any[];
|
||||
oauth2_additional_parameters_refresh_token_req_bodyvalues?: any[];
|
||||
}
|
||||
|
||||
interface T_Oauth2ParameterMapping {
|
||||
@@ -41,18 +41,18 @@ interface T_Oauth2ParameterMapping {
|
||||
|
||||
const PARAMETER_MAPPINGS: T_Oauth2ParameterMapping[] = [
|
||||
// Authorization parameters (only for authorization_code grant type)
|
||||
{ type: 'authorization', sendIn: 'headers', source: 'oauth2_additional_parameters_authorization_headers' },
|
||||
{ type: 'authorization', sendIn: 'queryparams', source: 'oauth2_additional_parameters_authorization_queryparams' },
|
||||
{ type: 'authorization', sendIn: 'headers', source: 'oauth2_additional_parameters_auth_req_headers' },
|
||||
{ type: 'authorization', sendIn: 'queryparams', source: 'oauth2_additional_parameters_auth_req_queryparams' },
|
||||
|
||||
// Token parameters (for all grant types)
|
||||
{ type: 'token', sendIn: 'headers', source: 'oauth2_additional_parameters_token_headers' },
|
||||
{ type: 'token', sendIn: 'queryparams', source: 'oauth2_additional_parameters_token_queryparams' },
|
||||
{ type: 'token', sendIn: 'body', source: 'oauth2_additional_parameters_token_bodyvalues' },
|
||||
{ type: 'token', sendIn: 'headers', source: 'oauth2_additional_parameters_access_token_req_headers' },
|
||||
{ type: 'token', sendIn: 'queryparams', source: 'oauth2_additional_parameters_access_token_req_queryparams' },
|
||||
{ type: 'token', sendIn: 'body', source: 'oauth2_additional_parameters_access_token_req_bodyvalues' },
|
||||
|
||||
// Refresh parameters (for grant types that support refresh)
|
||||
{ type: 'refresh', sendIn: 'headers', source: 'oauth2_additional_parameters_refresh_headers' },
|
||||
{ type: 'refresh', sendIn: 'queryparams', source: 'oauth2_additional_parameters_refresh_queryparams' },
|
||||
{ type: 'refresh', sendIn: 'body', source: 'oauth2_additional_parameters_refresh_bodyvalues' },
|
||||
{ type: 'refresh', sendIn: 'headers', source: 'oauth2_additional_parameters_refresh_token_req_headers' },
|
||||
{ type: 'refresh', sendIn: 'queryparams', source: 'oauth2_additional_parameters_refresh_token_req_queryparams' },
|
||||
{ type: 'refresh', sendIn: 'body', source: 'oauth2_additional_parameters_refresh_token_req_bodyvalues' },
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,17 +29,17 @@ const { safeParseJson, outdentString } = require('./utils');
|
||||
*
|
||||
*/
|
||||
const grammar = ohm.grammar(`Bru {
|
||||
BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs | authOAuth2Configs)*
|
||||
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey
|
||||
BruFile = (meta | http | query | params | headers | auths | bodies | varsandassert | script | tests | settings | docs)*
|
||||
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey | authOauth2Configs
|
||||
bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body
|
||||
bodyforms = bodyformurlencoded | bodymultipart | bodyfile
|
||||
params = paramspath | paramsquery
|
||||
|
||||
// Oauth2 additional parameters
|
||||
authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig
|
||||
oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams
|
||||
oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues
|
||||
oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues
|
||||
authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig
|
||||
oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams
|
||||
oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody
|
||||
oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody
|
||||
|
||||
nl = "\\r"? "\\n"
|
||||
st = " " | "\\t"
|
||||
@@ -111,14 +111,14 @@ const grammar = ohm.grammar(`Bru {
|
||||
authwsse = "auth:wsse" dictionary
|
||||
authapikey = "auth:apikey" dictionary
|
||||
|
||||
oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary
|
||||
oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary
|
||||
oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary
|
||||
oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary
|
||||
oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary
|
||||
oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary
|
||||
oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary
|
||||
oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary
|
||||
oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary
|
||||
oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary
|
||||
oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary
|
||||
oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary
|
||||
oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary
|
||||
oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary
|
||||
oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary
|
||||
oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary
|
||||
|
||||
body = "body" st* "{" nl* textblock tagend
|
||||
bodyjson = "body:json" st* "{" nl* textblock tagend
|
||||
@@ -655,44 +655,44 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
||||
}
|
||||
};
|
||||
},
|
||||
oAuth2AuthorizationHeaders(_1, dictionary) {
|
||||
oauth2AuthReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_auth_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2AuthorizationQueryParams(_1, dictionary) {
|
||||
oauth2AuthReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_auth_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenHeaders(_1, dictionary) {
|
||||
oauth2AccessTokenReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenQueryParams(_1, dictionary) {
|
||||
oauth2AccessTokenReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenBodyValues(_1, dictionary) {
|
||||
oauth2AccessTokenReqBody(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshHeaders(_1, dictionary) {
|
||||
oauth2RefreshTokenReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshQueryParams(_1, dictionary) {
|
||||
oauth2RefreshTokenReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshBodyValues(_1, dictionary) {
|
||||
oauth2RefreshTokenReqBody(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
authwsse(_1, dictionary) {
|
||||
|
||||
@@ -3,14 +3,14 @@ const _ = require('lodash');
|
||||
const { safeParseJson, outdentString } = require('./utils');
|
||||
|
||||
const grammar = ohm.grammar(`Bru {
|
||||
BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs | authOAuth2Configs)*
|
||||
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey
|
||||
BruFile = (meta | query | headers | auth | auths | vars | script | tests | docs)*
|
||||
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM |authOAuth2 | authwsse | authapikey | authOauth2Configs
|
||||
|
||||
// Oauth2 additional parameters
|
||||
authOAuth2Configs = oAuth2AuthorizationConfig | oAuth2TokenConfig | oAuth2RefreshConfig
|
||||
oAuth2AuthorizationConfig = oAuth2AuthorizationHeaders | oAuth2AuthorizationQueryParams
|
||||
oAuth2TokenConfig = oAuth2TokenHeaders | oAuth2TokenQueryParams | oAuth2TokenBodyValues
|
||||
oAuth2RefreshConfig = oAuth2RefreshHeaders | oAuth2RefreshQueryParams | oAuth2RefreshBodyValues
|
||||
authOauth2Configs = oauth2AuthReqConfig | oauth2AccessTokenReqConfig | oauth2RefreshTokenReqConfig
|
||||
oauth2AuthReqConfig = oauth2AuthReqHeaders | oauth2AuthReqQueryParams
|
||||
oauth2AccessTokenReqConfig = oauth2AccessTokenReqHeaders | oauth2AccessTokenReqQueryParams | oauth2AccessTokenReqBody
|
||||
oauth2RefreshTokenReqConfig = oauth2RefreshTokenReqHeaders | oauth2RefreshTokenReqQueryParams | oauth2RefreshTokenReqBody
|
||||
|
||||
nl = "\\r"? "\\n"
|
||||
st = " " | "\\t"
|
||||
@@ -36,14 +36,14 @@ const grammar = ohm.grammar(`Bru {
|
||||
|
||||
auth = "auth" dictionary
|
||||
|
||||
oAuth2AuthorizationHeaders = "auth:oauth2:authorization_headers" dictionary
|
||||
oAuth2AuthorizationQueryParams = "auth:oauth2:authorization_queryparams" dictionary
|
||||
oAuth2TokenHeaders = "auth:oauth2:token_headers" dictionary
|
||||
oAuth2TokenQueryParams = "auth:oauth2:token_queryparams" dictionary
|
||||
oAuth2TokenBodyValues = "auth:oauth2:token_bodyvalues" dictionary
|
||||
oAuth2RefreshHeaders = "auth:oauth2:refresh_headers" dictionary
|
||||
oAuth2RefreshQueryParams = "auth:oauth2:refresh_queryparams" dictionary
|
||||
oAuth2RefreshBodyValues = "auth:oauth2:refresh_bodyvalues" dictionary
|
||||
oauth2AuthReqHeaders = "auth:oauth2:additional_params:auth_req:headers" dictionary
|
||||
oauth2AuthReqQueryParams = "auth:oauth2:additional_params:auth_req:queryparams" dictionary
|
||||
oauth2AccessTokenReqHeaders = "auth:oauth2:additional_params:access_token_req:headers" dictionary
|
||||
oauth2AccessTokenReqQueryParams = "auth:oauth2:additional_params:access_token_req:queryparams" dictionary
|
||||
oauth2AccessTokenReqBody = "auth:oauth2:additional_params:access_token_req:body" dictionary
|
||||
oauth2RefreshTokenReqHeaders = "auth:oauth2:additional_params:refresh_token_req:headers" dictionary
|
||||
oauth2RefreshTokenReqQueryParams = "auth:oauth2:additional_params:refresh_token_req:queryparams" dictionary
|
||||
oauth2RefreshTokenReqBody = "auth:oauth2:additional_params:refresh_token_req:body" dictionary
|
||||
|
||||
headers = "headers" dictionary
|
||||
|
||||
@@ -377,44 +377,44 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
||||
}
|
||||
};
|
||||
},
|
||||
oAuth2AuthorizationHeaders(_1, dictionary) {
|
||||
oauth2AuthReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_authorization_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_auth_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2AuthorizationQueryParams(_1, dictionary) {
|
||||
oauth2AuthReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_authorization_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_auth_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenHeaders(_1, dictionary) {
|
||||
oauth2AccessTokenReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenQueryParams(_1, dictionary) {
|
||||
oauth2AccessTokenReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2TokenBodyValues(_1, dictionary) {
|
||||
oauth2AccessTokenReqBody(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_token_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_access_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshHeaders(_1, dictionary) {
|
||||
oauth2RefreshTokenReqHeaders(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_headers: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshQueryParams(_1, dictionary) {
|
||||
oauth2RefreshTokenReqQueryParams(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_queryparams: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
oAuth2RefreshBodyValues(_1, dictionary) {
|
||||
oauth2RefreshTokenReqBody(_1, dictionary) {
|
||||
return {
|
||||
oauth2_additional_parameters_refresh_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
oauth2_additional_parameters_refresh_token_req_bodyvalues: mapPairListToKeyValPairs(dictionary.ast)
|
||||
};
|
||||
},
|
||||
authwsse(_1, dictionary) {
|
||||
|
||||
@@ -286,7 +286,7 @@ ${indentString(`auto_fetch_token: ${(auth?.oauth2?.autoFetchToken ?? true).toStr
|
||||
const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters;
|
||||
const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (authorizationHeaders?.length) {
|
||||
bru += `auth:oauth2:authorization_headers {
|
||||
bru += `auth:oauth2:additional_params:auth_req:headers {
|
||||
${indentString(
|
||||
authorizationHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -299,7 +299,7 @@ ${indentString(
|
||||
}
|
||||
const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (authorizationQueryParams?.length) {
|
||||
bru += `auth:oauth2:authorization_queryparams {
|
||||
bru += `auth:oauth2:additional_params:auth_req:queryparams {
|
||||
${indentString(
|
||||
authorizationQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -312,7 +312,7 @@ ${indentString(
|
||||
}
|
||||
const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (tokenHeaders?.length) {
|
||||
bru += `auth:oauth2:token_headers {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:headers {
|
||||
${indentString(
|
||||
tokenHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -325,7 +325,7 @@ ${indentString(
|
||||
}
|
||||
const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (tokenQueryParams?.length) {
|
||||
bru += `auth:oauth2:token_queryparams {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:queryparams {
|
||||
${indentString(
|
||||
tokenQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -338,7 +338,7 @@ ${indentString(
|
||||
}
|
||||
const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body');
|
||||
if (tokenBodyValues?.length) {
|
||||
bru += `auth:oauth2:token_bodyvalues {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:body {
|
||||
${indentString(
|
||||
tokenBodyValues
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -351,7 +351,7 @@ ${indentString(
|
||||
}
|
||||
const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (refreshHeaders?.length) {
|
||||
bru += `auth:oauth2:refresh_headers {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:headers {
|
||||
${indentString(
|
||||
refreshHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -364,7 +364,7 @@ ${indentString(
|
||||
}
|
||||
const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (refreshQueryParams?.length) {
|
||||
bru += `auth:oauth2:refresh_queryparams {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:queryparams {
|
||||
${indentString(
|
||||
refreshQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -377,7 +377,7 @@ ${indentString(
|
||||
}
|
||||
const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body');
|
||||
if (refreshBodyValues?.length) {
|
||||
bru += `auth:oauth2:refresh_bodyvalues {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:body {
|
||||
${indentString(
|
||||
refreshBodyValues
|
||||
.filter(item => item?.name?.length)
|
||||
|
||||
@@ -239,7 +239,7 @@ ${indentString(`auto_refresh_token: ${(auth?.oauth2?.autoRefreshToken ?? false).
|
||||
const { authorization: authorizationParams, token: tokenParams, refresh: refreshParams } = auth?.oauth2?.additionalParameters;
|
||||
const authorizationHeaders = authorizationParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (authorizationHeaders?.length) {
|
||||
bru += `auth:oauth2:authorization_headers {
|
||||
bru += `auth:oauth2:additional_params:auth_req:headers {
|
||||
${indentString(
|
||||
authorizationHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -252,7 +252,7 @@ ${indentString(
|
||||
}
|
||||
const authorizationQueryParams = authorizationParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (authorizationQueryParams?.length) {
|
||||
bru += `auth:oauth2:authorization_queryparams {
|
||||
bru += `auth:oauth2:additional_params:auth_req:queryparams {
|
||||
${indentString(
|
||||
authorizationQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -265,7 +265,7 @@ ${indentString(
|
||||
}
|
||||
const tokenHeaders = tokenParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (tokenHeaders?.length) {
|
||||
bru += `auth:oauth2:token_headers {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:headers {
|
||||
${indentString(
|
||||
tokenHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -278,7 +278,7 @@ ${indentString(
|
||||
}
|
||||
const tokenQueryParams = tokenParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (tokenQueryParams?.length) {
|
||||
bru += `auth:oauth2:token_queryparams {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:queryparams {
|
||||
${indentString(
|
||||
tokenQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -291,7 +291,7 @@ ${indentString(
|
||||
}
|
||||
const tokenBodyValues = tokenParams?.filter(p => p?.sendIn == 'body');
|
||||
if (tokenBodyValues?.length) {
|
||||
bru += `auth:oauth2:token_bodyvalues {
|
||||
bru += `auth:oauth2:additional_params:access_token_req:body {
|
||||
${indentString(
|
||||
tokenBodyValues
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -304,7 +304,7 @@ ${indentString(
|
||||
}
|
||||
const refreshHeaders = refreshParams?.filter(p => p?.sendIn == 'headers');
|
||||
if (refreshHeaders?.length) {
|
||||
bru += `auth:oauth2:refresh_headers {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:headers {
|
||||
${indentString(
|
||||
refreshHeaders
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -317,7 +317,7 @@ ${indentString(
|
||||
}
|
||||
const refreshQueryParams = refreshParams?.filter(p => p?.sendIn == 'queryparams');
|
||||
if (refreshQueryParams?.length) {
|
||||
bru += `auth:oauth2:refresh_queryparams {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:queryparams {
|
||||
${indentString(
|
||||
refreshQueryParams
|
||||
.filter(item => item?.name?.length)
|
||||
@@ -330,7 +330,7 @@ ${indentString(
|
||||
}
|
||||
const refreshBodyValues = refreshParams?.filter(p => p?.sendIn == 'body');
|
||||
if (refreshBodyValues?.length) {
|
||||
bru += `auth:oauth2:refresh_bodyvalues {
|
||||
bru += `auth:oauth2:additional_params:refresh_token_req:body {
|
||||
${indentString(
|
||||
refreshBodyValues
|
||||
.filter(item => item?.name?.length)
|
||||
|
||||
@@ -29,86 +29,8 @@ const outdentString = (str) => {
|
||||
.join('\n');
|
||||
};
|
||||
|
||||
const mergeOauth2AdditionalParameters = (ast) => {
|
||||
let additionalParameters = {};
|
||||
const authorizationHeaders = ast?.oauth2_additional_parameters_authorization_headers;
|
||||
const authorizationQueryParams = ast?.oauth2_additional_parameters_authorization_queryparams;
|
||||
const tokenHeaders = ast?.oauth2_additional_parameters_token_headers;
|
||||
const tokenQueryParams = ast?.oauth2_additional_parameters_token_queryparams;
|
||||
const tokenBodyValues = ast?.oauth2_additional_parameters_token_bodyvalues;
|
||||
const refreshHeaders = ast?.oauth2_additional_parameters_refresh_headers;
|
||||
const refreshQueryParams = ast?.oauth2_additional_parameters_refresh_queryparams;
|
||||
const refreshBodyValues = ast?.oauth2_additional_parameters_refresh_bodyvalues;
|
||||
|
||||
if (ast?.auth?.oauth2?.grantType == 'authorization_code') {
|
||||
if (authorizationHeaders?.length || authorizationQueryParams?.length) {
|
||||
additionalParameters['authorization'] = []
|
||||
}
|
||||
if (authorizationHeaders?.length) {
|
||||
additionalParameters['authorization'] = [
|
||||
...authorizationHeaders?.map(_ => ({ ..._, sendIn: 'headers' }))
|
||||
]
|
||||
}
|
||||
if (authorizationQueryParams?.length) {
|
||||
additionalParameters['authorization'] = [
|
||||
...additionalParameters['authorization'] || [],
|
||||
...authorizationQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' }))
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenHeaders?.length || tokenQueryParams?.length || tokenBodyValues?.length) {
|
||||
additionalParameters['token'] = []
|
||||
}
|
||||
if (tokenHeaders?.length) {
|
||||
additionalParameters['token'] = [
|
||||
...tokenHeaders?.map(_ => ({ ..._, sendIn: 'headers' }))
|
||||
]
|
||||
}
|
||||
if (tokenQueryParams?.length) {
|
||||
additionalParameters['token'] = [
|
||||
...additionalParameters['token'] || [],
|
||||
...tokenQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' }))
|
||||
]
|
||||
}
|
||||
if (tokenBodyValues?.length) {
|
||||
additionalParameters['token'] = [
|
||||
...additionalParameters['token'] || [],
|
||||
...tokenBodyValues?.map(_ => ({ ..._, sendIn: 'body' }))
|
||||
]
|
||||
}
|
||||
|
||||
if (refreshHeaders?.length || refreshQueryParams?.length || refreshBodyValues?.length) {
|
||||
additionalParameters['refresh'] = []
|
||||
}
|
||||
if (refreshHeaders?.length) {
|
||||
additionalParameters['refresh'] = [
|
||||
...refreshHeaders?.map(_ => ({ ..._, sendIn: 'headers' }))
|
||||
]
|
||||
}
|
||||
if (refreshQueryParams?.length) {
|
||||
additionalParameters['refresh'] = [
|
||||
...additionalParameters['refresh'] || [],
|
||||
...refreshQueryParams?.map(_ => ({ ..._, sendIn: 'queryparams' }))
|
||||
]
|
||||
}
|
||||
if (refreshBodyValues?.length) {
|
||||
additionalParameters['refresh'] = [
|
||||
...additionalParameters['refresh'] || [],
|
||||
...refreshBodyValues?.map(_ => ({ ..._, sendIn: 'body' }))
|
||||
]
|
||||
}
|
||||
|
||||
if(ast?.auth?.oauth2 && Object.keys(additionalParameters)?.length) {
|
||||
ast.auth.oauth2.additionalParameters = additionalParameters;
|
||||
}
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
safeParseJson,
|
||||
indentString,
|
||||
outdentString,
|
||||
mergeOauth2AdditionalParameters
|
||||
outdentString
|
||||
};
|
||||
|
||||
@@ -21,42 +21,42 @@ auth:oauth2 {
|
||||
access_token_url: https://auth.usebruno.com/oauth/token
|
||||
}
|
||||
|
||||
auth:oauth2:authorization_headers {
|
||||
auth:oauth2:additional_params:auth_req:headers {
|
||||
auth-header: auth-header-value
|
||||
~disabled-auth-header: disabled-auth-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:authorization_queryparams {
|
||||
auth:oauth2:additional_params:auth_req:queryparams {
|
||||
auth-query-param: auth-query-param-value
|
||||
~disabled-auth-query-param: disabled-auth-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_headers {
|
||||
auth:oauth2:additional_params:access_token_req:headers {
|
||||
token-header: token-header-value
|
||||
~disabled-token-header: disabled-token-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_queryparams {
|
||||
auth:oauth2:additional_params:access_token_req:queryparams {
|
||||
token-query-param: token-query-param-value
|
||||
~disabled-token-query-param: disabled-token-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_bodyvalues {
|
||||
auth:oauth2:additional_params:access_token_req:body {
|
||||
token-body: token-body-value
|
||||
~disabled-token-body: disabled-token-body-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_headers {
|
||||
auth:oauth2:additional_params:refresh_token_req:headers {
|
||||
refresh-header: refresh-header-value
|
||||
~disabled-refresh-header: disabled-refresh-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_queryparams {
|
||||
auth:oauth2:additional_params:refresh_token_req:queryparams {
|
||||
refresh-query-param: refresh-query-param-value
|
||||
~disabled-refresh-query-param: disabled-refresh-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_bodyvalues {
|
||||
auth:oauth2:additional_params:refresh_token_req:body {
|
||||
refresh-body: refresh-body-value
|
||||
~disabled-refresh-body: disabled-refresh-body-value
|
||||
}
|
||||
@@ -65,27 +65,27 @@ auth:oauth2:refresh_bodyvalues {
|
||||
const result = bruToJson(input);
|
||||
|
||||
// Verify all config types are present
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_authorization_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_authorization_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_bodyvalues');
|
||||
|
||||
// Verify each has exactly one parameter
|
||||
expect(result.oauth2_additional_parameters_authorization_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_authorization_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_auth_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_auth_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toHaveLength(2);
|
||||
|
||||
// Verify parameter values
|
||||
expect(result.oauth2_additional_parameters_authorization_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_auth_req_headers).toEqual([{
|
||||
name: 'auth-header',
|
||||
value: 'auth-header-value',
|
||||
enabled: true
|
||||
@@ -95,7 +95,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_authorization_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_auth_req_queryparams).toEqual([{
|
||||
name: 'auth-query-param',
|
||||
value: 'auth-query-param-value',
|
||||
enabled: true
|
||||
@@ -105,7 +105,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_headers).toEqual([{
|
||||
name: 'token-header',
|
||||
value: 'token-header-value',
|
||||
enabled: true
|
||||
@@ -115,7 +115,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_queryparams).toEqual([{
|
||||
name: 'token-query-param',
|
||||
value: 'token-query-param-value',
|
||||
enabled: true
|
||||
@@ -125,7 +125,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_bodyvalues).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toEqual([{
|
||||
name: 'token-body',
|
||||
value: 'token-body-value',
|
||||
enabled: true
|
||||
@@ -135,7 +135,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_headers).toEqual([{
|
||||
name: 'refresh-header',
|
||||
value: 'refresh-header-value',
|
||||
enabled: true
|
||||
@@ -145,7 +145,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toEqual([{
|
||||
name: 'refresh-query-param',
|
||||
value: 'refresh-query-param-value',
|
||||
enabled: true
|
||||
@@ -155,7 +155,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_bodyvalues).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toEqual([{
|
||||
name: 'refresh-body',
|
||||
value: 'refresh-body-value',
|
||||
enabled: true
|
||||
@@ -182,42 +182,42 @@ auth:oauth2 {
|
||||
access_token_url: https://auth.usebruno.com/oauth/token
|
||||
}
|
||||
|
||||
auth:oauth2:authorization_headers {
|
||||
auth:oauth2:additional_params:auth_req:headers {
|
||||
auth-header: auth-header-value
|
||||
~disabled-auth-header: disabled-auth-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:authorization_queryparams {
|
||||
auth:oauth2:additional_params:auth_req:queryparams {
|
||||
auth-query-param: auth-query-param-value
|
||||
~disabled-auth-query-param: disabled-auth-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_headers {
|
||||
auth:oauth2:additional_params:access_token_req:headers {
|
||||
token-header: token-header-value
|
||||
~disabled-token-header: disabled-token-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_queryparams {
|
||||
auth:oauth2:additional_params:access_token_req:queryparams {
|
||||
token-query-param: token-query-param-value
|
||||
~disabled-token-query-param: disabled-token-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:token_bodyvalues {
|
||||
auth:oauth2:additional_params:access_token_req:body {
|
||||
token-body: token-body-value
|
||||
~disabled-token-body: disabled-token-body-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_headers {
|
||||
auth:oauth2:additional_params:refresh_token_req:headers {
|
||||
refresh-header: refresh-header-value
|
||||
~disabled-refresh-header: disabled-refresh-header-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_queryparams {
|
||||
auth:oauth2:additional_params:refresh_token_req:queryparams {
|
||||
refresh-query-param: refresh-query-param-value
|
||||
~disabled-refresh-query-param: disabled-refresh-query-param-value
|
||||
}
|
||||
|
||||
auth:oauth2:refresh_bodyvalues {
|
||||
auth:oauth2:additional_params:refresh_token_req:body {
|
||||
refresh-body: refresh-body-value
|
||||
~disabled-refresh-body: disabled-refresh-body-value
|
||||
}
|
||||
@@ -226,27 +226,27 @@ auth:oauth2:refresh_bodyvalues {
|
||||
const result = collectionBruToJson(input);
|
||||
|
||||
// Verify all config types are present
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_authorization_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_authorization_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_token_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_auth_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_access_token_req_bodyvalues');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_headers');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_queryparams');
|
||||
expect(result).toHaveProperty('oauth2_additional_parameters_refresh_token_req_bodyvalues');
|
||||
|
||||
// Verify each has exactly one parameter
|
||||
expect(result.oauth2_additional_parameters_authorization_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_authorization_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_token_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_auth_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_auth_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_headers).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toHaveLength(2);
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toHaveLength(2);
|
||||
|
||||
// Verify parameter values
|
||||
expect(result.oauth2_additional_parameters_authorization_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_auth_req_headers).toEqual([{
|
||||
name: 'auth-header',
|
||||
value: 'auth-header-value',
|
||||
enabled: true
|
||||
@@ -256,7 +256,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_authorization_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_auth_req_queryparams).toEqual([{
|
||||
name: 'auth-query-param',
|
||||
value: 'auth-query-param-value',
|
||||
enabled: true
|
||||
@@ -266,7 +266,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_headers).toEqual([{
|
||||
name: 'token-header',
|
||||
value: 'token-header-value',
|
||||
enabled: true
|
||||
@@ -276,7 +276,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_queryparams).toEqual([{
|
||||
name: 'token-query-param',
|
||||
value: 'token-query-param-value',
|
||||
enabled: true
|
||||
@@ -286,7 +286,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_token_bodyvalues).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_access_token_req_bodyvalues).toEqual([{
|
||||
name: 'token-body',
|
||||
value: 'token-body-value',
|
||||
enabled: true
|
||||
@@ -296,7 +296,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_headers).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_headers).toEqual([{
|
||||
name: 'refresh-header',
|
||||
value: 'refresh-header-value',
|
||||
enabled: true
|
||||
@@ -306,7 +306,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_queryparams).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_queryparams).toEqual([{
|
||||
name: 'refresh-query-param',
|
||||
value: 'refresh-query-param-value',
|
||||
enabled: true
|
||||
@@ -316,7 +316,7 @@ auth:oauth2:refresh_bodyvalues {
|
||||
enabled: false
|
||||
}]);
|
||||
|
||||
expect(result.oauth2_additional_parameters_refresh_bodyvalues).toEqual([{
|
||||
expect(result.oauth2_additional_parameters_refresh_token_req_bodyvalues).toEqual([{
|
||||
name: 'refresh-body',
|
||||
value: 'refresh-body-value',
|
||||
enabled: true
|
||||
|
||||
Reference in New Issue
Block a user