Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #208 Add sign out uri(s) field in app form #222

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export interface AppDetailModel {
* Gets the app revisions redirect uri (or uris) where a user will be redirected to immediately after a successful authentication
*/
redirectUris?: string[]
/**
duong-se marked this conversation as resolved.
Show resolved Hide resolved
* Sets the apps logout uris.
*/
signoutUris?: string[]
/**
* Gets the date the app was installed for a specific client
*/
Expand Down Expand Up @@ -391,6 +395,10 @@ export interface CreateAppModel {
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed as a comma separated list
*/
redirectUris?: string[]
/**
* Sets the apps logout uris.
*/
signoutUris?: string[]
duong-se marked this conversation as resolved.
Show resolved Hide resolved
/**
* Sets the unique identifer of the developer registering the app
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports[`DeveloperSubmitApp should match a snapshot 1`] = `
"screen3ImageUrl": "",
"screen4ImageUrl": "",
"screen5ImageUrl": "",
"signoutUris": "",
"summary": "",
"supportEmail": "",
"telephone": "",
Expand Down Expand Up @@ -93,6 +94,7 @@ exports[`DeveloperSubmitApp should match submit revision form snapshot 1`] = `
],
"screen1ImageUrl": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png",
"screen2ImageUrl": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png",
"signoutUris": "",
"summary": "vitae elementum curabitur vitae nunc sed velit eget gravida cum sociis natoque!!",
"supportEmail": "[email protected]",
"telephone": "0113 288 2900",
Expand Down
32 changes: 29 additions & 3 deletions packages/marketplace/src/components/pages/developer-submit-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import { selectCategories } from '../../selector/app-categories'
import styles from '@/styles/pages/developer-submit-app.scss?mod'
import { TermsAndConditionsModal } from '../ui/terms-and-conditions-modal'

export type CustomCreateAppModel = Omit<CreateAppModel, 'redirectUris'> & { redirectUris?: string }
export type CustomCreateAppModel = Omit<CreateAppModel, 'redirectUris' | 'signoutUris'> & {
redirectUris?: string
signoutUris?: string
}

export interface SubmitAppMappedActions {
submitApp: (
Expand Down Expand Up @@ -102,6 +105,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
isDirectApi,
scopes: appScopes,
redirectUris = [],
signoutUris = [],
} = appDetail

const icon = (media || []).filter(({ order }) => order === 0)[0]
Expand All @@ -128,6 +132,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
isDirectApi,
scopes: appScopes ? appScopes.map(item => item.name) : [],
redirectUris: redirectUris.join(','),
signoutUris: signoutUris.join(','),
...images,
}
} else {
Expand All @@ -150,6 +155,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
developerId,
scopes: [],
redirectUris: '',
signoutUris: '',
}
}

Expand All @@ -170,15 +176,23 @@ export const handleSubmitApp = ({
}
if (!appId) {
submitApp(
{ ...appModel, redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [] },
{
...appModel,
redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [],
signoutUris: appModel.signoutUris ? appModel.signoutUris.split(',') : [],
},
actions,
setSubmitError,
)
} else {
if (appModel.authFlow) {
delete appModel.authFlow
}
submitRevision(appId, { ...appModel, redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [] })
submitRevision(appId, {
...appModel,
redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [],
signoutUris: appModel.signoutUris ? appModel.signoutUris.split(',') : [],
})
}
}

Expand Down Expand Up @@ -387,6 +401,18 @@ export const SubmitApp: React.FC<SubmitAppProps> = ({
/>
</GridItem>
</Grid>
<Grid>
<GridItem>
<Input
dataTest="submit-app-signout-uris"
type="text"
labelText="Sign Out URI(s)"
id="signoutUris"
name="signoutUris"
placeholder="Enter the URI that your application should navigate to when a user logs out. For multiple URI's, separate using a comma. HTTPS other than for http://localhost"
/>
</GridItem>
</Grid>
<Grid>
<GridItem>
<TextArea
Expand Down
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/marketplace/src/utils/form/__tests__/submit-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('submitAppValidation', () => {
summary: '',
scopes: [],
redirectUris: '',
signoutUris: '',
}

const validateRequiredKeys = [
Expand All @@ -32,6 +33,7 @@ describe('submitAppValidation', () => {
'screen1ImageUrl',
'summary',
'redirectUris',
'signoutUris',
]

const output = {}
Expand All @@ -58,6 +60,7 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({
Expand All @@ -81,13 +84,38 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'http://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({
redirectUris: 'Invalid redirect uri(s)',
})
})

it('validate sign out uri(s) field ', () => {
const input: CustomCreateAppModel = {
screen4ImageUrl: 'test',
screen3ImageUrl: 'test',
screen2ImageUrl: 'test',
screen1ImageUrl: 'test',
name: 'test',
telephone: 'test',
supportEmail: '[email protected]',
launchUri: 'test',
iconImageUrl: 'test',
homePage: 'test',
description: 'test',
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'https://localhost:8080',
}

expect(validate(input)).toEqual({
signoutUris: 'Invalid sign out uri(s)',
})
})

it('return empty object it everything is valid', () => {
const input: CustomCreateAppModel = {
screen4ImageUrl: 'test',
Expand All @@ -104,6 +132,7 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({})
Expand Down
6 changes: 6 additions & 0 deletions packages/marketplace/src/utils/form/submit-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type SubmitAppFormErrorKeys =
| 'screen1ImageUrl'
| 'authFlow'
| 'redirectUris'
| 'signoutUris'

export const validate = (values: CustomCreateAppModel) => {
let errors = validateRequire<CustomCreateAppModel, SubmitAppFormErrorKeys>({
Expand All @@ -31,6 +32,7 @@ export const validate = (values: CustomCreateAppModel) => {
'screen1ImageUrl',
'authFlow',
'redirectUris',
'signoutUris',
],
})

Expand All @@ -44,5 +46,9 @@ export const validate = (values: CustomCreateAppModel) => {
errors.redirectUris = 'Invalid redirect uri(s)'
}

if (values.signoutUris && !isValidRedirectUrls(values.signoutUris)) {
errors.signoutUris = 'Invalid sign out uri(s)'
}

return errors
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19013,7 +19013,7 @@ redux-persist@^5.10.0:
resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b"
integrity sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg==

redux-saga@^1.1.1:
redux-saga@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-1.1.3.tgz#9f3e6aebd3c994bbc0f6901a625f9a42b51d1112"
integrity sha512-RkSn/z0mwaSa5/xH/hQLo8gNf4tlvT18qXDNvedihLcfzh+jMchDgaariQoehCpgRltEm4zHKJyINEz6aqswTw==
Expand Down