React animations with animate.css
Simple, minimal, and task-focused application for creating screenshots. Available for LInux, MacOS, WIndows
random static pages
kurdin/alt-react-router-example 0
An example project showing a way to use React-Router (and async calls) with the Flux implementation, Alt.
A simple flux tutorial built with alt and react
The easiest way to find, use and share animations. Priceless!
Tiny animation library
jQuery plugin to dynamically apply animate.css animations
A powerful little tool for managing CSS animations
pull request commentnearform/titus
feat: test casbin integration for auth providers
@simoneb @mcollina - thank you both for the feedback - I think I've addressed all the issues raised and it's much improved.
comment created time in 4 minutes
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)+ // we added the user to role with admin access above in the server.onReady hook+ // Here's where the actual policy check goes ahead - based on the user's email+ if (+ !(await server.casbin.enforce(authzUserData.email, 'admin', 'access'))+ ) {+ throw new Forbidden('Cannot access admin')+ }+ }+ ],+ handler: async req => {+ return {+ isAdmin: true,+ user: req.user+ }+ }+ })
done - moved. Much better :)
comment created time in 5 minutes
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)+ // we added the user to role with admin access above in the server.onReady hook+ // Here's where the actual policy check goes ahead - based on the user's email+ if (+ !(await server.casbin.enforce(authzUserData.email, 'admin', 'access'))+ ) {+ throw new Forbidden('Cannot access admin')+ }+ }
yes, makes sense, thank you.
comment created time in 5 minutes
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)
Exactly - the accessToken doesn't always contain any useful information for assigning roles - but all the auth providers all also define idToken with more user info like email
comment created time in 5 minutes
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })
yes, defining the dependencies is much better. - Thanks
comment created time in 8 minutes
startedpisa-engine/pisa
started time in 3 hours
startedtantivy-search/tantivy
started time in 3 hours
push eventnearform/brokeneck
commit sha 6723ff93c187281f0e117a5ffb06c02d70540340
test: react components (#57) * test: add error boundary tests * test: created EntityFields test * test: created GraphQLErrorBoundary test * test: create group tests * test: create user tests * test: remove unnecessary rerender * test: change getAllByRole to GetByRole * test: fix test mocking * test: fix issue with CI date * test: fix coverage
push time in 3 hours
PR merged nearform/brokeneck
created tests for the ErrorBoundary, EntityFields, GraphQLErrorBoundary, User, Group
pr closed time in 3 hours
push eventnearform/brokeneck
commit sha ccee4f9a6e4bda3ca746a42bce538bc29d869bbf
test: fix coverage
push time in 9 hours
startedutkarshkukreti/select.rs
started time in 11 hours
push eventnearform/brokeneck
commit sha 4aa293caf7c206d4662690f059576b691afa126f
test: fix issue with CI date
push time in 11 hours
push eventnearform/brokeneck
commit sha 0d08ae817e0ff7349cda62e986415a87650ae86c
test: remove unnecessary rerender
commit sha f166ab7818798461a0b410d27680be253cd4aab3
test: change getAllByRole to GetByRole
commit sha d447fd2f386c57d5ddee1a171e4ca4a50e455f5c
Merge branch 'master' of https://github.com/nearform/brokeneck into test/react-components
commit sha e1b295deb8f10312587a2964537bc87989f7bfe7
test: fix test mocking
push time in 11 hours
push eventnearform/brokeneck
commit sha b94b80db1def05857d136b7a7774e64f1ee34bbb
test: adjust coverage thresholds
push time in 13 hours
push eventnearform/brokeneck
commit sha 86fded645691a63a8c6eea15ca4062205fb84ac4
feat: edit entities (#56)
commit sha 2bc4e669f7e2583377e299083620f045d60827b3
test: add error boundary tests
commit sha 8cdd2b087a1a54f87db31d334ad2bbdf26f42bed
test: created EntityFields test
commit sha 7a96c42f4c0f8779f8790423a7cde26bf8cd6028
test: created GraphQLErrorBoundary test
commit sha 80fbd946a0226735f434b583e654ea049c2f73de
test: create group tests
commit sha 1c89473acc228fe8873681c4718a096483854abc
test: create user tests
commit sha 464bf2237d5a3795d96633e94cf3426a4291bb85
test: use locale-independent assertion on dates
commit sha 9f3b527622378552c9fb1b0d79b3034a6ac33fdb
test: fix mock root context
commit sha c7e22d773283af611ef1c9892ad5b67f0aae6d0a
Merge branch 'test/react-components' of https://github.com/nearform/brokeneck into test/react-components
push time in 13 hours
push eventnearform/titus
commit sha a997c5901445fec370c0f3b971f57b72a2d43cb7
fix(deps): update dependency pino to ^6.10.0 (#679) Co-authored-by: Renovate Bot <[email protected]>
push time in 13 hours
PR merged nearform/titus
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| pino (source) | ^6.9.0 -> ^6.10.0 |
Release Notes
<details> <summary>pinojs/pino</summary>
v6.10.0
📚 PR:
- Bump up pino-std-serializers dependency (#946)
</details>
Renovate configuration
:date: Schedule: At any time (no schedule defined).
:vertical_traffic_light: Automerge: Enabled.
:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
This PR has been generated by WhiteSource Renovate. View repository job log here.
pr closed time in 13 hours
push eventnearform/brokeneck
commit sha 84ef7548b4381d174b10996e3c3bc236615495ae
test: use locale-independent assertion on dates
push time in 13 hours
pull request commentnearform/titus
fix(deps): update dependency pino to ^6.10.0
Branch automerge failure
This PR was configured for branch automerge, however this is not possible so it has been raised as a PR instead.
comment created time in 15 hours
PR opened nearform/titus
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| pino (source) | ^6.9.0 -> ^6.10.0 |
Release Notes
<details> <summary>pinojs/pino</summary>
v6.10.0
📚 PR:
- Bump up pino-std-serializers dependency (#946)
</details>
Renovate configuration
:date: Schedule: At any time (no schedule defined).
:vertical_traffic_light: Automerge: Enabled.
:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
This PR has been generated by WhiteSource Renovate. View repository job log here.
pr created time in 15 hours
Pull request review commentnearform/brokeneck
+import React from 'react'+import T from 'prop-types'+import { screen, render, waitFor, fireEvent } from '@testing-library/react'+import { useQuery } from 'graphql-hooks'+import deepmerge from 'deepmerge'++import mockRootContext from '../test-utils/mockRootContext'+import { withThemeSwitcher, withRouter } from '../test-utils/providers'+import { LOAD_ROOT } from '../graphql'++import RootContext from './RootContext'+import User from './User'++const RootContextWrapper = ({ children }) => {+ return (+ <RootContext.Provider value={mockRootContext}>+ {children}+ </RootContext.Provider>+ )+}++RootContextWrapper.propTypes = {+ children: T.node+}++const withProviders = (children, options) => {+ const { path = '/users' } = options || {}+ return withThemeSwitcher(withRouter(children, path))+}++const mockUseQuery = (overrides = {}) => query => {+ let data = {}++ if (query === LOAD_ROOT) {+ data = mockRootContext+ }++ if (/query LoadUsers\(/.test(query)) {+ data = {+ users: { data: [], nextPage: '234567' }+ }+ }++ if (/query LoadUser\(/.test(query)) {+ data = {+ user: {+ Username: 'a_user',+ Enabled: true,+ UserStatus: 'FORCE_CHANGE_PASSWORD',+ UserCreateDate: '2021-01-07T12:33:07.571Z',+ UserLastModifiedDate: '2021-01-07T12:33:07.571Z',+ groups: [+ {+ GroupName: 'AnotherGroup',+ Description: 'Another group description',+ CreationDate: '2021-01-05T10:42:20.733Z',+ LastModifiedDate: '2021-01-05T10:42:20.733Z',+ users: { data: [], nextPage: '234567' }+ }+ ]+ },+ groups: { data: [], nextPage: '234567' }+ }+ }++ if (/query LoadGroups\(/.test(query)) {+ data = {+ groups: { data: [], nextPage: '234567' }+ }+ }++ if (/query LoadGroup\(/.test(query)) {+ data = {+ group: {+ GroupName: 'AnotherGroup',+ Description: 'Another group description',+ CreationDate: '2021-01-05T10:42:20.733Z',+ LastModifiedDate: '2021-01-05T10:42:20.733Z',+ users: { data: [], nextPage: '234567' }+ },+ users: { data: [], nextPage: '234567' }+ }+ }++ return deepmerge({ data, loading: false }, overrides)+}++const mockMutation = jest.fn()++jest.mock('graphql-hooks', () => {+ const originalLib = jest.requireActual('graphql-hooks')++ return {+ ...originalLib,+ useMutation: jest.fn().mockImplementation(() => [mockMutation]),+ useQuery: jest.fn()+ }+})++const mockGoBack = jest.fn()++jest.mock('react-router-dom', () => {+ const originalLib = jest.requireActual('react-router-dom')++ return {+ ...originalLib,+ useHistory: jest.fn().mockImplementation(() => ({ goBack: mockGoBack })),+ useQuery: jest.fn()+ }+})++afterEach(() => {+ jest.clearAllMocks()+})++describe('user', () => {+ it('should render user component', () => {+ useQuery.mockImplementation(mockUseQuery())++ render(withProviders(<User userId="1234" />), {+ wrapper: RootContextWrapper+ })++ expect(screen.getByText(/Add to group/i)).toBeInTheDocument()+ expect(screen.getByText(/Delete user/i)).toBeInTheDocument()+ expect(screen.getAllByTestId(/user-group-chip/i).length).toEqual(1)+ })++ it('should open delete dialog when "Delete user" clicked', async () => {+ useQuery.mockImplementation(mockUseQuery())++ render(withProviders(<User userId="1234" />), {+ wrapper: RootContextWrapper+ })+ screen.getAllByRole('button', { name: /Delete user/i })[0].click()++ expect(screen.getByTestId('dialog-form')).toBeInTheDocument()+ expect(screen.getByRole('button', { name: 'Confirm' })).toBeInTheDocument()+ })++ it('should delete user when "Delete user" dialog submitted', async () => {+ useQuery.mockImplementation(mockUseQuery())++ render(withProviders(<User userId="1234" />), {+ wrapper: RootContextWrapper+ })+ screen.getAllByRole('button', { name: /Delete user/i })[0].click()++ fireEvent.submit(screen.getByTestId('dialog-form'))++ await waitFor(() =>
The wairFor is required because otherwise the promise the promise form the dialog box awaiting the submit isnt fully resolved, meaning that the mutation function is not fired by the time the tests get here. Not having the wait for causes them to fail. as a result of the function call not yet occuring
comment created time in 19 hours
created repositorycodesandbox/codesandbox-client-refactor
Experimental project to refactor CodeSandbox client with in-house state management tool
created time in 19 hours
Pull request review commentnearform/brokeneck
+import React from 'react'+import { screen, render } from '@testing-library/react'++import ErrorBoundary from './ErrorBoundary'++const ThrowError = ({ shouldThrow }) => {+ if (shouldThrow) {+ throw new Error('Custom error message')+ } else {+ return null+ }+}++beforeEach(() => {+ // eslint-disable-next-line no-console+ console.error = jest.fn()
This is being mocked because even when the test passes because the error is being handled the terminal logs the console.error message and clutters the test output. This avoids that unnecessary logging
comment created time in 19 hours
startedsnowpackjs/snowpack
started time in a day
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)+ // we added the user to role with admin access above in the server.onReady hook+ // Here's where the actual policy check goes ahead - based on the user's email+ if (+ !(await server.casbin.enforce(authzUserData.email, 'admin', 'access'))+ ) {+ throw new Forbidden('Cannot access admin')+ }+ }+ ],+ handler: async req => {+ return {+ isAdmin: true,+ user: req.user+ }+ }+ })
Yep similar to what I commented. Let's move this route registration as a standalone module in /routes.
comment created time in a day
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)
I believe, but I'll let Adam explain, that this is a different token than the one we already used. What we used is an access token and this one is an id token.
comment created time in a day
Pull request review commentnearform/titus
feat: test casbin integration for auth providers
+'use strict'++const fp = require('fastify-plugin')+const { Forbidden } = require('http-errors')+const jwt = require('jsonwebtoken')++async function authRoutes(server, options) {+ // add users to the admin role+ server.addHook('onReady', async function () {+ const adminUsers = process.env.CHECK_AUTHZ_ADMIN_USERS || ''+ const policies = adminUsers+ .split(',')+ .map(u => server.casbin.addRoleForUser(u, 'role_admin'))+ await Promise.all(policies)+ })++ // this is a sample to check the signed-in user's permission to access this resource via casbin policies based on configuration in the OAuth provider+ // a real-world example would have more context around the user account and roles/scopes/permissions and policies+ server.route({+ method: 'GET',+ url: '/authzcheck',+ schema: {+ tags: ['authz'],+ security: [+ {+ apiKey: []+ }+ ]+ },+ onRequest: [+ server.authenticate,+ async (request, res) => {+ const authzId = request.headers['x-authz-id']+ const authzUserData = jwt.decode(authzId)+ // we added the user to role with admin access above in the server.onReady hook+ // Here's where the actual policy check goes ahead - based on the user's email+ if (+ !(await server.casbin.enforce(authzUserData.email, 'admin', 'access'))+ ) {+ throw new Forbidden('Cannot access admin')+ }+ }+ ],+ handler: async req => {+ return {+ isAdmin: true,+ user: req.user+ }+ }+ })
I would not include a route inside something in /plugins, it should be in /routes.
comment created time in a day