Skip to content

Commit

Permalink
Merge pull request #3573 from FlowFuse/fix-http-token-create
Browse files Browse the repository at this point in the history
HTTP Bearer Tokens test for correct flag
  • Loading branch information
knolleary authored Mar 14, 2024
2 parents 3603b03 + 6d58a9d commit 80231d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion forge/ee/routes/httpTokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = async function (app) {
return
}
const teamType = await request.project.Team.getTeamType()
if (!teamType.getFeatureProperty('ha', true)) {
if (!teamType.getFeatureProperty('teamHttpSecurity', false)) {
reply.code(404).send({ code: 'not_found', error: 'Not Found' })
return // eslint-disable-line no-useless-return
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/frontend/test_environment_ee.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const { Roles } = FF_UTIL.require('forge/lib/roles')
const defaultTeamTypeProperties = defaultTeamType.properties
defaultTeamTypeProperties.features.deviceGroups = true
defaultTeamTypeProperties.features.protectedInstance = true
defaultTeamTypeProperties.features.teamHttpSecurity = true
defaultTeamType.properties = defaultTeamTypeProperties
await defaultTeamType.save()

Expand Down
20 changes: 19 additions & 1 deletion test/unit/forge/ee/routes/httpTokens/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const should = require('should') // eslint-disable-line
const setup = require('../../setup')

const FF_UTIL = require('flowforge-test-utils')
const { Roles } = FF_UTIL.require('forge/lib/roles')
const { START_DELAY } = FF_UTIL.require('forge/containers/stub/index.js')

describe('NR HTTP Bearer Tokens', function () {
Expand All @@ -16,13 +17,29 @@ describe('NR HTTP Bearer Tokens', function () {
app = await setup()
await login('alice', 'aaPassword')

// setup FF Auth for team type
const defaultTeamTypeProperties = app.defaultTeamType.properties
defaultTeamTypeProperties.features.teamHttpSecurity = true
app.defaultTeamType.properties = defaultTeamTypeProperties
await app.defaultTeamType.save()

TestObjects.BTeam = await app.db.models.Team.create({ name: 'BTeam', TeamTypeId: app.defaultTeamType.id })
await TestObjects.BTeam.addUser(TestObjects.alice, { through: { role: Roles.Owner } })
await app.factory.createSubscription(TestObjects.BTeam)

TestObjects.application = await app.db.models.Application.create({
name: 'B-team Application',
description: 'B-team Application description',
TeamId: TestObjects.BTeam.id
})

// Create a new instance
const response = await app.inject({
method: 'POST',
url: '/api/v1/projects',
payload: {
name: 'test-tokens-project-1',
applicationId: app.application.hashid,
applicationId: TestObjects.application.hashid,
projectType: app.projectType.hashid,
template: app.template.hashid,
stack: app.stack.hashid
Expand All @@ -36,6 +53,7 @@ describe('NR HTTP Bearer Tokens', function () {

after(async function () {
await app.close()
setup.resetStripe()
})

async function login (username, password) {
Expand Down

0 comments on commit 80231d6

Please sign in to comment.