mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
add groups feature
This commit is contained in:
parent
6fd750dad5
commit
7f5dc4c152
119 changed files with 12416 additions and 402 deletions
42
lib/util/fakegroup.js
Normal file
42
lib/util/fakegroup.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
||||
**/
|
||||
|
||||
const util = require('util')
|
||||
const uuid = require('uuid')
|
||||
const dbapi = require('../db/api')
|
||||
const apiutil = require('./apiutil')
|
||||
|
||||
module.exports.generate = function() {
|
||||
return dbapi.getRootGroup().then(function(rootGroup) {
|
||||
const now = Date.now()
|
||||
|
||||
return dbapi.createUserGroup({
|
||||
name: 'fakegroup-' + util.format('%s', uuid.v4()).replace(/-/g, '')
|
||||
, owner: {
|
||||
email: rootGroup.owner.email
|
||||
, name: rootGroup.owner.name
|
||||
}
|
||||
, privilege: apiutil.ADMIN
|
||||
, class: apiutil.BOOKABLE
|
||||
, repetitions: 0
|
||||
, isActive: true
|
||||
, dates: apiutil.computeGroupDates(
|
||||
{
|
||||
start: new Date(now)
|
||||
, stop: new Date(now + apiutil.ONE_YEAR)
|
||||
}
|
||||
, apiutil.BOOKABLE
|
||||
, 0
|
||||
)
|
||||
, duration: 0
|
||||
, state: apiutil.READY
|
||||
})
|
||||
.then(function(group) {
|
||||
if (group) {
|
||||
return group.id
|
||||
}
|
||||
throw new Error('Forbidden (groups number quota is reached)')
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue