Ejemplo n.º 1
0
def create(client, user_id, group_id):
    try:
        credentials = cred_lib.create(client, user_id, group_id)
        utils.check(credentials)
        click.secho(f"Credentials created", fg="green")
    except Exception as exc:
        click.secho(
            f"Credential creation failed. \n{exc}", fg="yellow", bold=True, err=True
        )
Ejemplo n.º 2
0
    def post(self):
        args = init_parser().parse_args()

        try:
            status = credential.create(get_client(), args["userId"],
                                       args["groupId"])
            if "reason" in status:
                current_app.logger.error(status["reason"])
                return response(status["status_code"],
                                message=status["reason"])

            return response(
                201,
                f"User {args['userId']} new credential created successfully.")
        except Exception as e:
            current_app.logger.error(f"{e}", exc_info=args["debug"])
            return response(500, f"{e}")
Ejemplo n.º 3
0
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument("userId", type=str, required=True)
        parser.add_argument("groupId", type=str, required=True)
        args = parser.parse_args()

        try:
            status = credential.create(get_client(), args["userId"],
                                       args["groupId"])
            if "reason" in status:
                current_app.logger.error(status["reason"])
                return response(status["status_code"],
                                message=status["reason"])

            return response(
                201,
                f"User {args['userId']} new credential created successfully.")
        except Exception as e:
            current_app.logger.error(f"{e}")
            return response(500, f"{e}")
Ejemplo n.º 4
0
def test_create():
    assert cred.create(fake_client(), "user", "group") == "Done"