Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f784472857 | ||
|
|
c888daf9b4 |
@@ -0,0 +1,81 @@
|
|||||||
|
openapi: "3.0.0"
|
||||||
|
info:
|
||||||
|
version: 1.0.0
|
||||||
|
title: Brentertainment OAuth2 Test Server
|
||||||
|
description: >
|
||||||
|
The server does not support CORS (yet?), so you need to take the strange step of disabling Same-Origin Policy in your browser.
|
||||||
|
[Here](https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/) are some instructions.
|
||||||
|
license:
|
||||||
|
name: MIT
|
||||||
|
servers:
|
||||||
|
- url: http://brentertainment.com/oauth2/lockdin/
|
||||||
|
paths:
|
||||||
|
/resource:
|
||||||
|
get:
|
||||||
|
description: Protected resource
|
||||||
|
security:
|
||||||
|
- oauth2AuthorizationCode: ["resource"]
|
||||||
|
- oauth2Implicit: ["resource"]
|
||||||
|
- oauth2Password: ["resource"]
|
||||||
|
- oauth2ClientCredentials: ["resource"]
|
||||||
|
- oauth2Multiflow: ["resource"]
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: the only response
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
oauth2AuthorizationCode:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
authorizationCode:
|
||||||
|
authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
oauth2Implicit:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
oauth2Password:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
password:
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
oauth2ClientCredentials:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
clientCredentials:
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
oauth2Multiflow:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
clientCredentials:
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
password:
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
|
authorizationCode:
|
||||||
|
authorizationUrl: "http://brentertainment.com/oauth2/lockdin/authorize"
|
||||||
|
tokenUrl: "http://brentertainment.com/oauth2/lockdin/token"
|
||||||
|
scopes:
|
||||||
|
resource: our only scope
|
||||||
@@ -99,10 +99,13 @@ export default class Auths extends React.Component {
|
|||||||
{
|
{
|
||||||
definitions.filter( schema => schema.get("type") === "oauth2")
|
definitions.filter( schema => schema.get("type") === "oauth2")
|
||||||
.map( (schema, name) =>{
|
.map( (schema, name) =>{
|
||||||
return (<div key={ name }>
|
const { flow } = schema
|
||||||
|
const key = [name, flow].join("__").slice(0, -2)
|
||||||
|
return (<div key={ key }>
|
||||||
<Oauth2 authorized={ authorized }
|
<Oauth2 authorized={ authorized }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
name={ name } />
|
authId={ key }
|
||||||
|
name={ key || schema.get("name") || name } />
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
).toArray()
|
).toArray()
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ export default class Oauth2 extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
authorize =() => {
|
authorize =() => {
|
||||||
let { authActions, errActions, getConfigs, authSelectors } = this.props
|
let { authActions, errActions, getConfigs, authSelectors, authId } = this.props
|
||||||
let configs = getConfigs()
|
let configs = getConfigs()
|
||||||
let authConfigs = authSelectors.getConfigs()
|
let authConfigs = authSelectors.getConfigs()
|
||||||
|
|
||||||
errActions.clear({authId: name,type: "auth", source: "auth"})
|
errActions.clear({authId: authId ,type: "auth", source: "auth"})
|
||||||
oauth2Authorize({auth: this.state, authActions, errActions, configs, authConfigs })
|
oauth2Authorize({auth: this.state, authActions, errActions, configs, authConfigs })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,15 +79,15 @@ export default class Oauth2 extends React.Component {
|
|||||||
|
|
||||||
logout =(e) => {
|
logout =(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
let { authActions, errActions, name } = this.props
|
let { authActions, errActions, authId } = this.props
|
||||||
|
|
||||||
errActions.clear({authId: name, type: "auth", source: "auth"})
|
errActions.clear({authId: authId, type: "auth", source: "auth"})
|
||||||
authActions.logout([ name ])
|
authActions.logout([ authId ])
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let {
|
let {
|
||||||
schema, getComponent, authSelectors, errSelectors, name, specSelectors
|
schema, getComponent, authSelectors, errSelectors, name, authId, specSelectors
|
||||||
} = this.props
|
} = this.props
|
||||||
const Input = getComponent("Input")
|
const Input = getComponent("Input")
|
||||||
const Row = getComponent("Row")
|
const Row = getComponent("Row")
|
||||||
@@ -107,9 +107,9 @@ export default class Oauth2 extends React.Component {
|
|||||||
|
|
||||||
let flow = schema.get("flow")
|
let flow = schema.get("flow")
|
||||||
let scopes = schema.get("allowedScopes") || schema.get("scopes")
|
let scopes = schema.get("allowedScopes") || schema.get("scopes")
|
||||||
let authorizedAuth = authSelectors.authorized().get(name)
|
let authorizedAuth = authSelectors.authorized().get(authId)
|
||||||
let isAuthorized = !!authorizedAuth
|
let isAuthorized = !!authorizedAuth
|
||||||
let errors = errSelectors.allErrors().filter( err => err.get("authId") === name)
|
let errors = errSelectors.allErrors().filter( err => err.get("authId") === authId)
|
||||||
let isValid = !errors.filter( err => err.get("source") === "validation").size
|
let isValid = !errors.filter( err => err.get("source") === "validation").size
|
||||||
let description = schema.get("description")
|
let description = schema.get("description")
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export const definitionsToAuthorize = onlyOAS3(createSelector(
|
|||||||
definition.get("flows").entrySeq().forEach(([flowKey, flowVal]) => {
|
definition.get("flows").entrySeq().forEach(([flowKey, flowVal]) => {
|
||||||
let translatedDef = fromJS({
|
let translatedDef = fromJS({
|
||||||
flow: flowKey,
|
flow: flowKey,
|
||||||
|
name: defName,
|
||||||
authorizationUrl: flowVal.get("authorizationUrl"),
|
authorizationUrl: flowVal.get("authorizationUrl"),
|
||||||
tokenUrl: flowVal.get("tokenUrl"),
|
tokenUrl: flowVal.get("tokenUrl"),
|
||||||
scopes: flowVal.get("scopes"),
|
scopes: flowVal.get("scopes"),
|
||||||
@@ -40,7 +41,7 @@ export const definitionsToAuthorize = onlyOAS3(createSelector(
|
|||||||
})
|
})
|
||||||
|
|
||||||
list = list.push(new Map({
|
list = list.push(new Map({
|
||||||
[defName]: translatedDef.filter((v) => {
|
[`${defName}__${flowKey}`]: translatedDef.filter((v) => {
|
||||||
// filter out unset values, sometimes `authorizationUrl`
|
// filter out unset values, sometimes `authorizationUrl`
|
||||||
// and `tokenUrl` come out as `undefined` in the data
|
// and `tokenUrl` come out as `undefined` in the data
|
||||||
return v !== undefined
|
return v !== undefined
|
||||||
|
|||||||
@@ -118,7 +118,11 @@ export default {
|
|||||||
let operationPath = ["paths", ...path]
|
let operationPath = ["paths", ...path]
|
||||||
let metaPath = ["meta", "paths", ...path]
|
let metaPath = ["meta", "paths", ...path]
|
||||||
|
|
||||||
if(!state.getIn(["json", ...operationPath]) && !state.getIn(["resolved", ...operationPath])) {
|
if(
|
||||||
|
!state.getIn(["json", ...operationPath])
|
||||||
|
&& !state.getIn(["resolved", ...operationPath])
|
||||||
|
&& !state.getIn(["resolvedSubtrees", ...operationPath])
|
||||||
|
) {
|
||||||
// do nothing if the operation does not exist
|
// do nothing if the operation does not exist
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
describe("bug #4485: operation metadata storage when referenced via path item $ref", function () {
|
||||||
|
let mainPage
|
||||||
|
beforeEach(function (client, done) {
|
||||||
|
mainPage = client
|
||||||
|
.url("localhost:3230")
|
||||||
|
.page.main()
|
||||||
|
|
||||||
|
client.waitForElementVisible(".download-url-input", 5000)
|
||||||
|
.pause(2000)
|
||||||
|
.clearValue(".download-url-input")
|
||||||
|
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4485/main.yaml")
|
||||||
|
.click("button.download-url-button")
|
||||||
|
.pause(1000)
|
||||||
|
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
afterEach(function (client, done) {
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
it("sets a consumes value for a body parameter correctly", function (client) {
|
||||||
|
client.waitForElementVisible(".opblock-tag-section", 10000)
|
||||||
|
.click(".opblock")
|
||||||
|
.waitForElementVisible(".opblock-body", 5000)
|
||||||
|
.click("button.btn.try-out__btn")
|
||||||
|
.click("select.content-type [value=\"application/xml\"]")
|
||||||
|
.pause(500)
|
||||||
|
.assert.value("select.content-type", "application/xml")
|
||||||
|
|
||||||
|
client.end()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
post:
|
||||||
|
description: Book
|
||||||
|
operationId: buy
|
||||||
|
summary: Buy a book
|
||||||
|
tags:
|
||||||
|
- Book
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
- application/xml
|
||||||
|
parameters:
|
||||||
|
- name: requestBody
|
||||||
|
in: body
|
||||||
|
description: Buy a Book
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
swagger: '2.0'
|
||||||
|
paths:
|
||||||
|
"/v1/book":
|
||||||
|
"$ref": "./book.yaml"
|
||||||
Reference in New Issue
Block a user