Skip to content

Commit

Permalink
fix: test require auth, admin service is protected (#187)
Browse files Browse the repository at this point in the history
alternatively, we can remove the requires annotation in the local
bookshop sample in the tests
  • Loading branch information
johannes-vogel authored Dec 5, 2024
1 parent a204b12 commit 03b6a3f
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/tests/graphiql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - GraphiQL', () => {
const { axios, GET } = cds.test(path.join(__dirname, '../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

test('GET request to endpoint should serve HTML containing GraphiQL', async () => {
const response = await GET('/graphql')
Expand Down
3 changes: 3 additions & 0 deletions test/tests/localized.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - queries with localized data', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/mutations/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - create mutations', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/mutations/delete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - delete mutations', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/mutations/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - update mutations', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/aliases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - aliases', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with aliases without connections', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - filter', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/fragments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - fragments', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with fragments without connections', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - meta fields', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with __typename meta field without connections', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/orderBy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - orderBy', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with orderBy argument without connections', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/paging-offset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - offset-based paging', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with paging arguments without connections', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - queries', () => {
const { axios, POST, data } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

beforeEach(async () => {
await data.reset()
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/totalCount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - queries with totalCount', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

test('simple query with totalCount', async () => {
const query = gql`
Expand Down
3 changes: 3 additions & 0 deletions test/tests/queries/variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe('graphql - variables', () => {
const { axios, POST } = cds.test(path.join(__dirname, '../../resources/bookshop-graphql'))
// Prevent axios from throwing errors for non 2xx status codes
axios.defaults.validateStatus = false
axios.defaults.headers = {
authorization: 'Basic YWxpY2U6'
}

// REVISIT: unskip for support of configurable schema flavors
describe.skip('queries with variables without connections', () => {
Expand Down

0 comments on commit 03b6a3f

Please sign in to comment.