Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chef 1493 - OCID Integration #7909

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
939c283
Chef 2588/add OCID component in automate (#7861)
ayush-billore May 10, 2023
e5faf69
Dynamically set webui key from erchef to ocid (#7878)
RajeshPaul38 May 10, 2023
c956f6f
update value for WriteMetadata to false in spec.go
ayush-billore May 15, 2023
23db08b
Configure environment variables for ocid component (#7889)
RajeshPaul38 May 18, 2023
baf14d4
fixed default.toml for automate-cs-ocid component for chef_server_config
RajeshPaul38 May 24, 2023
74bc2ed
Chef 2424/configure nginx and unicorn (#7899)
ayush-billore May 24, 2023
5ee8676
Register applications with OCID: chef-server-ctl reconfigure alternat…
RajeshPaul38 Jun 2, 2023
53f4dbc
Fix the run hook for null values (#7952)
saghoshprogress Jun 6, 2023
d697142
Chef 2426 - Add Integration tests for OCID integration (#7924)
ayush-billore Jun 21, 2023
732a97b
Chef 3749 - Add additional Integration tests (#7988)
ayush-billore Jun 26, 2023
c1ea027
fix ocid test file name
ayush-billore Jun 27, 2023
0047b45
move config patch to a seperate block
ayush-billore Jun 27, 2023
93172de
Chef 1493 - PR Review Suggestions (#7999)
ayush-billore Jun 28, 2023
a5a8fed
Generate secret_key_base for OCID rails app (#7932)
RajeshPaul38 Jul 3, 2023
096ba62
Add validation logic for OCID redirect uri (#8029)
ayush-billore Jul 4, 2023
940528f
Removed unnecessary flags from oc-id-show-app for automate HA (#8060)
RajeshPaul38 Jul 13, 2023
4be84b6
Resolve PR review comments for CHEF-1493 (#8059)
ayush-billore Jul 17, 2023
f04e3c1
OCID Integration fix pipeline (#8065)
ayush-billore Jul 17, 2023
5a8412a
remove stale depsolver changes from default.toml of ocid component
ayush-billore Jul 19, 2023
ec44f40
Added docs for oc-id-show-app command (#8069)
RajeshPaul38 Jul 19, 2023
70a4206
Backup configuration created for OCID (#8068)
RajeshPaul38 Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .bldr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ paths = [
"api/config/minio/*",
"api/config/nodemanager/*",
"api/config/notifications/*",
"api/config/ocid/*",
"api/config/opensearch/*",
"api/config/pg_gateway/*",
"api/config/pg_sidecar/*",
Expand Down Expand Up @@ -408,6 +409,7 @@ paths = [
"api/config/minio/*",
"api/config/nodemanager/*",
"api/config/notifications/*",
"api/config/ocid/*",
"api/config/opensearch/*",
"api/config/pg_gateway/*",
"api/config/pg_sidecar/*",
Expand Down Expand Up @@ -511,6 +513,7 @@ paths = [
"api/config/minio/*",
"api/config/nodemanager/*",
"api/config/notifications/*",
"api/config/ocid/*",
"api/config/opensearch/*",
"api/config/pg_gateway/*",
"api/config/pg_sidecar/*",
Expand Down Expand Up @@ -943,6 +946,12 @@ paths = [
"components/automate-cs-oc-erchef/*"
]

[automate-cs-ocid]
plan_path = "components/automate-cs-ocid"
paths = [
"components/automate-cs-ocid/*"
]

[automate-cs-nginx]
plan_path = "components/automate-cs-nginx"
paths = [
Expand Down
1 change: 1 addition & 0 deletions .expeditor/update_chef_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ file_for_pkg=(
[bookshelf]="components/automate-cs-bookshelf/habitat/plan.sh"
[oc_bifrost]="components/automate-cs-oc-bifrost/habitat/plan.sh"
[oc_erchef]="components/automate-cs-oc-erchef/habitat/plan.sh"
[oc_id]="components/automate-cs-ocid/habitat/plan.sh"
[openresty-noroot]="components/automate-workflow-nginx/habitat/plan.sh"
)

Expand Down
26 changes: 26 additions & 0 deletions .expeditor/verify_private.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -929,3 +929,29 @@ steps:
executor:
linux:
privileged: true

- label: "ocid"
command:
- integration/run_test integration/tests/testing_ocid.sh
timeout_in_minutes: 15
expeditor:
secrets:
A2_LICENSE:
path: secret/a2/license
field: license
executor:
linux:
privileged: true

- label: "ocid config patch"
command:
- integration/run_test integration/tests/testing_ocid_config_patch.sh
timeout_in_minutes: 15
expeditor:
secrets:
A2_LICENSE:
path: secret/a2/license
field: license
executor:
linux:
privileged: true
1 change: 1 addition & 0 deletions .license_scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ directories:
- ./components/automate-cs-nginx
- ./components/automate-cs-oc-bifrost
- ./components/automate-cs-oc-erchef
- ./components/automate-cs-ocid
- ./components/automate-debug
- ./components/automate-deployment
- ./components/automate-dex
Expand Down
198 changes: 198 additions & 0 deletions .studio/chef-server-collection
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,141 @@ function test_knife() {
done
}

hab_curl() {
hab pkg exec core/curl curl "$@";
}

document "test_if_login_working_with_correct_credentials" <<DOC
login call returns 200 if creds are correct
DOC
test_if_login_working_with_correct_credentials() {
bootstrap_chef_user_data || return 1
local url="https://${chef_server_hostname}/id/auth/chef/callback"

res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" "$url" \
--header 'x-requested-with: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'utf8=✓' \
--data-urlencode "username=$chef_server_test_admin_user_email" \
--data-urlencode "password=$chef_server_test_user_password" \
--data-urlencode 'commit=Sign+In')

if [ "$res_code" == 200 ]; then
echo "User Logged In"
else
echo "Error Logging in with test admin user"
return 1
fi
}

document "test_if_login_failing_with_incorrect_credentials" <<DOC
login call returns 302 if creds are incorrect
DOC
test_if_login_failing_with_incorrect_credentials() {
bootstrap_chef_user_data || return 1
local url="https://${chef_server_hostname}/id/auth/chef/callback"
local incorrect_password='incorrect-password'

res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" "$url" \
--header 'x-requested-with: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'utf8=✓' \
--data-urlencode "username=$chef_server_test_admin_user_email" \
--data-urlencode "password=$incorrect_password" \
--data-urlencode 'commit=Sign+In')

if [ "$res_code" == 302 ]; then
echo "Login call returns HTTP STATUS 302 as expected for invalid credentials"
else
echo "Login call did not return HTTP STATUS 302 for invalid credentials"
return 1
fi
}

document "test_if_env_vars_are_configured" <<DOC
test if default ENV variables are configured for OCID
DOC
test_if_env_vars_are_configured() {
ocid_config_file_path="$(hab pkg path chef/oc_id)/oc_id/config/settings/production.yml"

# Get values from in settings/production.yml
endpoint=$(awk '/endpoint:/ {print $2}' "$ocid_config_file_path")
superuser=$(awk '/superuser:/ {print $2}' "$ocid_config_file_path")
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' "$ocid_config_file_path")

errors=()

if [ "$endpoint" != "https://127.0.0.1:443" ]; then
errors+=("Chef-Server endpoint is not configured properly.")
fi

if [ "$superuser" != "pivotal" ]; then
errors+=("Chef-Server superuser is not configured properly.")
fi

if [ "$ssl_verify_mode" != "verify_none" ]; then
errors+=("Chef-Server SSL certificate verification mode is not configured properly.")
fi

if [ ${#errors} -gt 0 ]; then
for (( i=0; i<${#errors[@]}; i++ )); do echo "${errors[$i]}" ; done
return 1
else
echo "ENV Vars configured correctly"
fi
}

# We are keeping a local copy of this method as the original from 01_base.sh is not accessible here
install_if_missing() {
if [ "$#" -ne 2 ]; then
error "Wrong number of arguments to ${FUNCNAME[0]}"
describe "${FUNCNAME[0]}"
return 1
fi

# Install the package if it is not installed
if [[ ! -d "/hab/pkgs/$1" ]]; then
hab pkg install "$1" > /dev/null
fi

# Ensure we are binlinking to the same version `hab pkg exec` would run
hab pkg binlink --force "$1" "$2" > /dev/null
}

document "test_if_webui_key_is_patched" <<DOC
test if WEB UI key is patched for OCID
DOC
test_if_webui_key_is_patched() {
install_if_missing core/jq-static jq

# Extract webui_key from private-chef-secrets.json
ocid_secrets_file_path="$(hab pkg path chef/oc_id)/oc_id/config/private-chef-secrets.json"

# elem variable hold the value 'chef-server', we opted for this syntax becz chef-server needs to be
# to be treated as string as it contains `-`, which is not a valid JSON character
ocid_webui_key="$(jq --arg elem "chef-server" -r '.[$elem]."webui_key"' < "$ocid_secrets_file_path")"

# Create a temporary file with the ocid_webui_key content
echo "$ocid_webui_key" > temp_ocid_webui_key.pem

# Path for erchef webui_priv.pem file
erchef_webui_key_path="/hab/svc/automate-cs-oc-erchef/data/webui_priv.pem"

# Compare the temporary file with the erchef PEM file
output=$(diff "$erchef_webui_key_path" temp_ocid_webui_key.pem)

# Remove the temporary file
rm temp_ocid_webui_key.pem

# Check if the output is empty, indicating a match
if [ -z "$output" ]; then
echo "The content of the PEM file matches."
else
echo "The content of the PEM file does not match."
return 1
fi
}

document "ohai_time" <<DOC
Gets ohai_time for a converged node. Assumes converge_chef_client has already run.
DOC
Expand All @@ -406,3 +541,66 @@ function ohai_time() {
-a ohai_time \
| grep ohai_time | cut -f2 -d":" | xargs
}

document "test_if_env_vars_are_configured_after_patch" <<DOC
test if OCID ENV variables are configured after patch
DOC
test_if_env_vars_are_configured_after_patch() {
ocid_config_file_path="$(hab pkg path chef/oc_id)/oc_id/config/settings/production.yml"

# Get values from in settings/production.yml
endpoint=$(awk '/endpoint:/ {print $2}' "$ocid_config_file_path")
superuser=$(awk '/superuser:/ {print $2}' "$ocid_config_file_path")
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' "$ocid_config_file_path")

errors=()

if [ "$endpoint" != "https://test-url.com:443" ]; then
errors+=("Chef-Server endpoint is not configured properly.")
fi

if [ "$superuser" != "testuser" ]; then
errors+=("Chef-Server superuser is not configured properly.")
fi

if [ "$ssl_verify_mode" != "verify_peer" ]; then
errors+=("Chef-Server SSL certificate verification mode is not configured properly.")
fi

if [ ${#errors} -gt 0 ]; then
for (( i=0; i<${#errors[@]}; i++ )); do echo "${errors[$i]}" ; done
return 1
else
echo "ENV Vars configured correctly"
fi
}

document "test_if_oauthapps_are_patched_correctly" <<DOC
test if OAuth App values are patched correctly
DOC
test_if_oauthapps_are_patched_correctly() {
chef-automate config oc-id-show-app > registered_oauth_apps.yml

yaml_file="registered_oauth_apps.yml"

# Extract values of attributes
name=$(grep -oP "(?<=name: ).*" "$yaml_file")
redirect_uri=$(grep -oP "(?<=redirect_uri: ).*" "$yaml_file")

errors=()

if [ "$name" != "test-supermarket" ]; then
errors+=("Registered OAuth application's name is not patched correctly.")
fi

if [ "$redirect_uri" != "https://sampleurl.com/auth/chef_oauth2/callback" ]; then
errors+=("Registered OAuth application's redirect URI is not configured correctly.")
fi

if [ ${#errors} -gt 0 ]; then
for (( i=0; i<${#errors[@]}; i++ )); do echo "${errors[$i]}" ; done
return 1
else
echo "OAuth App values are patched correctly"
fi
}
1 change: 1 addition & 0 deletions HABITAT_PACKAGES
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ trial-license-service components/trial-license-service
automate-cs-bookshelf components/automate-cs-bookshelf
automate-cs-oc-bifrost components/automate-cs-oc-bifrost
automate-cs-oc-erchef components/automate-cs-oc-erchef
automate-cs-ocid components/automate-cs-ocid
automate-cs-nginx components/automate-cs-nginx
automate-workflow-nginx components/automate-workflow-nginx
automate-workflow-web components/automate-workflow-web
Expand Down
8 changes: 7 additions & 1 deletion api/config/deployment/automate_config.pb.a2svc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading