User to query for "publicKey" is generated on port "4001"

But still no "publicKey" is generated.
So wished failing test shows not "publicKey" except other than "null".
This commit is contained in:
Wolfgang Huß 2019-04-05 18:32:11 +02:00
parent 8713f61734
commit c4e57fc928

View File

@ -1,3 +1,4 @@
import gql from 'graphql-tag'
import Factory from '../seed/factories' import Factory from '../seed/factories'
import { GraphQLClient, request } from 'graphql-request' import { GraphQLClient, request } from 'graphql-request'
import jwt from 'jsonwebtoken' import jwt from 'jsonwebtoken'
@ -313,7 +314,7 @@ describe('change password', () => {
describe('don\'t expose private RSA key', () => { describe('don\'t expose private RSA key', () => {
const queryUser = params => { const queryUser = params => {
const { queriedUserSlug } = params const { queriedUserSlug } = params
return ` return gql`
{ {
User(slug:"${queriedUserSlug}") { User(slug:"${queriedUserSlug}") {
id id
@ -338,17 +339,34 @@ describe('don\'t expose private RSA key', () => {
const hostPrivateKey = 'http://127.0.0.1:4001' // To have a "privateKey" generated. const hostPrivateKey = 'http://127.0.0.1:4001' // To have a "privateKey" generated.
// const hostPrivateKey = 'http://127.0.0.1:4123' // const hostPrivateKey = 'http://127.0.0.1:4123'
let client let client
// logged out
client = new GraphQLClient(hostPrivateKey)
// Generate user with "privateKey".
const id = 'bcb2d923-f3af-479e-9f00-61b12e864667'
const name = 'Apfel Strudel'
const slug = 'apfel-strudel'
const password = 'xYz'
await client.request(gql`
mutation {
CreateUser(id: "${id}", password: "${password}", slug:"${slug}", name: "${name}", email: "${slug}@test.org") {
id
}
}`
)
// logged in
const headers = await login({ email: 'test@example.org', password: '1234' }, hostPrivateKey) const headers = await login({ email: 'test@example.org', password: '1234' }, hostPrivateKey)
client = new GraphQLClient(hostPrivateKey, { headers }) client = new GraphQLClient(hostPrivateKey, { headers })
let response = await client.request( let response = await client.request(
queryUser({ queriedUserSlug: 'matilde-hermiston' }) queryUser({ queriedUserSlug: 'apfel-strudel' })
) )
await expect( await expect(
response response
).toEqual({ ).toEqual({
User: [{ User: [{
id: 'acb2d923-f3af-479e-9f00-61b12e864666', id: 'bcb2d923-f3af-479e-9f00-61b12e864667',
privateKey: 'XXX' privateKey: 'XXX'
// privateKey: null // privateKey: null
}] }]