From 163810947a6b9c523013f8ff1d3dc34776554b4b Mon Sep 17 00:00:00 2001 From: isha2040 <58481974+isha2040@users.noreply.github.com> Date: Tue, 27 Apr 2021 21:15:04 +0100 Subject: [PATCH] Fix role related failing script --- bin/register-role.sh | 27 ++++++++++----------------- package.json | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/bin/register-role.sh b/bin/register-role.sh index 523eac6..0237ecf 100755 --- a/bin/register-role.sh +++ b/bin/register-role.sh @@ -1,19 +1,12 @@ -#!/bin/sh -## Usage: ./idam-user-token.sh [user] [password] -## -## Options: -## - username: Role assigned to user in generated token. Default to `ccd.docker.default@hmcts.net`. -## - password: ID assigned to user in generated token. Default to `Pa55word11`. -## -## Returns a valid IDAM user token for the given username and password. +# Register role in CCD -IMPORTER_USERNAME=${1:-ccd.docker.default@hmcts.net} -IMPORTER_PASSWORD=${2:-Pa55word11} -IDAM_URI="http://localhost:5000" -REDIRECT_URI="http://localhost:3000/oauth2/callback" -CLIENT_ID="xuiwebapp" -CLIENT_SECRET=${OAUTH2_CLIENT_SECRET} -SCOPE="openid%20profile%20roles" +ROLE=$1 +USER_TOKEN=$2 +SERVICE_TOKEN=$3 -curl --silent -H "Content-Type: application/x-www-form-urlencoded" \ - -XPOST "${IDAM_URI}/o/token?grant_type=password&redirect_uri=${REDIRECT_URI}&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&username=${IMPORTER_USERNAME}&password=${IMPORTER_PASSWORD}&scope=${SCOPE}" -d "" | docker run --rm --interactive stedolan/jq -r .access_token \ No newline at end of file +curl --silent --show-error -XPUT \ + http://localhost:4451/api/user-role \ + -H "Authorization: Bearer ${USER_TOKEN}" \ + -H "ServiceAuthorization: Bearer ${SERVICE_TOKEN}" \ + -H "Content-Type: application/json" \ + -d '{"role":"'"${ROLE}"'","security_classification":"PUBLIC"}' \ No newline at end of file diff --git a/package.json b/package.json index 5ec9f18..9cb862b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/probate-dev-env", - "version": "1.0.46", + "version": "1.0.47", "description": "Scripts to set up the Probate development environment", "main": "index.js", "bin": {