Пример #1
0
def delete_user():
    data_must_contain = ['username']
    for k in data_must_contain:
        if k not in request.json:
            return jsonify({
                "status":
                " the request must have the following \
            information {}".format(json.dumps(data_must_contain))
            })
    username = request.json['username']
    print('i got the name from http argument {}'.format(username))
    record = af.delete_user(username)
    response_obj = {"status": record}
    return jsonify(response_obj)
Пример #2
0
 def test_delete_user(self):
     self.user_creation_for_test()
     status = af.delete_user('u1')
     self.assertTrue(status == "u1 has been  deleted successfully")
Пример #3
0
def main():
    if len(sys.argv) == 1:
        # display help message when no args are passed.
        parser.print_help()
        sys.exit(1)

    if sys.argv[1] == 'initdb':
        print("performing db table creation as per the last schema"
              " change in migration dir : {}".format(migration_path))
        os.environ["FLASK_APP"] = flask_app
        subprocess.run([
            "flask",
            "db",
            "upgrade",
            "-d",
            migration_path,
        ])

    #print(sys.argv[3])


#     options.name = options.name

    if sys.argv[1] == 'add':

        if options.entity == 'org':
            af.register_org(options.name)

        if options.entity == 'ou':
            af.register_ou(options.name)

        if options.entity == 'dept':
            af.register_dept(options.name)

        if options.entity == 'role':
            af.register_role(options.name)

    if sys.argv[1] == 'addwfc':
        af.register_work_func_context(options.name, options.wfcorg,
                                      options.wfcou, options.wfcdept)

    if sys.argv[1] == 'adduser':
        password = options.password
        username = options.name
        emailid = options.emailid
        rolenames = options.rolenames
        if rolenames:
            role_list = []
            if not ',' in rolenames:
                role_list.append(rolenames)
            else:
                role_list = rolenames.split(',')
            af.register_user(
                username,
                email=emailid,
                pwd=password,
                wfc_name=options.wfc,
                roles=role_list,
            )
        else:
            af.register_user(username,
                             email=emailid,
                             pwd=password,
                             wfc_name=options.wfc)
        #af.delete_user(options.name, options.email, options.password, options.roles)

    if sys.argv[1] == 'list':

        if options.entity == 'org':
            if options.name == 'all':
                af.list_org()
            else:
                af.list_org(options.name)

        if options.entity == 'ou':
            if options.name == 'all':
                af.list_ou()
            else:
                af.list_ou(options.name)

        if options.entity == 'dept':
            if options.name == 'all':
                af.list_dept()
            else:
                af.list_dept(options.name)

        if options.entity == 'wfc':
            if options.name == 'all':
                af.list_wfc()
            else:
                af.list_wfc(options.name)

        if options.entity == 'role':
            if options.name == 'all':
                af.list_role()
            else:
                af.list_role(options.name)

        if options.entity == 'user':
            if options.name == 'all':
                af.list_users()
            else:
                af.list_users(options.name)

    if sys.argv[1] == 'delete':

        if options.entity == 'org':
            af.delete_org(options.name)

        if options.entity == 'ou':
            af.delete_ou(options.name)

        if options.entity == 'dept':
            af.delete_dept(options.name)

        if options.entity == 'wfc':
            af.delete_wfc(options.name)

        if options.entity == 'role':
            af.delete_role(options.name)

        if options.entity == 'user':
            af.delete_user(options.name)

    if sys.argv[1] == 'addservice':
        cf.add_service(options.name,
                       pwd=options.password,
                       urlint=options.urlint,
                       urlext=options.urlext,
                       urladmin=options.urladmin)

    if sys.argv[1] == 'listservice':
        if options.name == 'all':
            cf.list_services()
        else:
            cf.list_services(options.name)

    if sys.argv[1] == 'deletservice':
        cf.delete_service(options.name)
Пример #4
0
def delete_user_restapi(username):
    status = af.delete_user(username)
    response_obj = {"status": status}
    return jsonify(response_obj)