Skip to content

Commit fb6e0f9

Browse files
committed
WIP
1 parent b7cac86 commit fb6e0f9

13 files changed

Lines changed: 2413 additions & 10 deletions

File tree

cncf-tests/cancel.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
gh run -s queued -R cncf/keycloak-testing list -L 100 --json databaseId | jq .[].databaseId -r | xargs -I {} echo gh run -R cncf/keycloak-testing cancel {}
4+
5+
gh run -s in_progress -R cncf/keycloak-testing list -L 100 --json databaseId | jq .[].databaseId -r | xargs -I {} echo gh run -R cncf/keycloak-testing cancel {}

cncf-tests/schedule-runs.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash -e
2+
3+
function help() {
4+
echo "Schedule many runs for a GitHub Actions workflow"
5+
echo
6+
echo "options:"
7+
echo "-b Branch to use (defaults to main)"
8+
echo "-w Workflow name (required)"
9+
echo "-n Number of runs (defaults to 100)"
10+
echo
11+
}
12+
13+
while getopts ":b:n:w:" option; do
14+
case $option in
15+
b)
16+
BRANCH=$OPTARG;;
17+
w)
18+
WORKFLOW=$OPTARG;;
19+
n)
20+
RUNS=$OPTARG;;
21+
*)
22+
help
23+
exit;;
24+
esac
25+
done
26+
27+
if [ "$RUNS" == "" ]; then
28+
RUNS=100
29+
fi
30+
31+
if [ "$WORKFLOW" == "" ]; then
32+
echo -e "Error: Workflow not specified\n" && help && exit 1
33+
fi
34+
35+
if [ "$BRANCH" == "" ]; then
36+
BRANCH="main"
37+
fi
38+
39+
USER=$(gh api user | jq -r '.login')
40+
41+
echo "Scheduling $RUNS run(s) in cncf/keycloak-testing for workflow $WORKFLOW and branch $BRANCH"
42+
echo ""
43+
44+
for i in $(seq 1 "$RUNS"); do
45+
echo -n "($i) "
46+
gh workflow run -R "cncf/keycloak-testing" -r "$BRANCH" "$WORKFLOW"
47+
done

cncf-tests/status.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash -e
2+
3+
function help() {
4+
echo "View status of GitHub Actions runs"
5+
echo
6+
echo "options:"
7+
echo "-b Branch to use (defaults to main)"
8+
echo "-w Workflow name (required)"
9+
echo "-d Date range (defaults to today)"
10+
echo
11+
}
12+
13+
while getopts ":b:d:w:" option; do
14+
case $option in
15+
b)
16+
BRANCH=$OPTARG;;
17+
w)
18+
WORKFLOW=$OPTARG;;
19+
d)
20+
DATE=$OPTARG;;
21+
*)
22+
help
23+
exit;;
24+
esac
25+
done
26+
27+
if [ "$DATE" == "" ]; then
28+
DATE=$(date -Idate)
29+
fi
30+
31+
if [ "$BRANCH" == "" ]; then
32+
BRANCH="main"
33+
fi
34+
35+
if [ "$WORKFLOW" == "" ]; then
36+
echo -e "Error: Workflow not specified\n" && help && exit 1
37+
fi
38+
39+
USER=$(gh api user | jq -r '.login')
40+
41+
echo "Status of $WORKFLOW in cncf/keycloak-testing for branch $BRANCH"
42+
echo ""
43+
44+
gh api -X GET "/repos/cncf/keycloak-testing/actions/workflows/$WORKFLOW/runs" -F branch="$BRANCH" -F per_page=100 --paginate -F created="$DATE" | jq -r '.workflow_runs[] | [.status, .conclusion] | @csv' | sort | uniq -c
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.github.stianst.gh;
2+
3+
import java.util.Arrays;
4+
5+
public class Convert {
6+
7+
static String input = "7m 48s\n" +
8+
"9m 14s\n" +
9+
"28m 29s\n" +
10+
"20m 28s\n" +
11+
"27m 42s\n" +
12+
"23m 48s\n" +
13+
"30m 17s\n" +
14+
"2m 23s\n" +
15+
"5m 22s\n" +
16+
"16m 0s\n" +
17+
"10m 40s\n" +
18+
"17m 59s\n" +
19+
"16m 55s\n" +
20+
"23m 15s\n" +
21+
"22m 17s\n" +
22+
"7m 29s\n" +
23+
"6m 26s\n" +
24+
"7m 26s\n" +
25+
"7m 26s\n" +
26+
"12m 41s\n" +
27+
"6m 17s\n" +
28+
"26m 37s\n" +
29+
"29m 31s\n" +
30+
"12m 20s\n" +
31+
"3m 14s\n" +
32+
"3m 11s\n" +
33+
"48m 23s\n" +
34+
"59m 31s\n" +
35+
"1h 15m 33s\n" +
36+
"40m 41s\n" +
37+
"4m 35s\n" +
38+
"9m 26s";
39+
40+
public static void main(String[] args) {
41+
Arrays.stream(input.split("\\n")).forEach(s -> {
42+
String[] split = s.split(" ");
43+
Integer hours = 0;
44+
Integer min;
45+
Integer sec;
46+
if (split.length == 2) {
47+
min = Integer.valueOf(split[0].replace("m", ""));
48+
sec = Integer.valueOf(split[1].replace("s", ""));
49+
} else {
50+
hours = Integer.valueOf(split[0].replace("h", ""));
51+
min = Integer.valueOf(split[1].replace("m", ""));
52+
sec = Integer.valueOf(split[2].replace("s", ""));
53+
}
54+
System.out.format("%02d:%02d:%02d\n", hours, min, sec);
55+
});
56+
}
57+
58+
}

gh/src/main/java/io/github/stianst/gh/RunningJobs.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.kohsuke.github.PagedIterable;
88

99
import java.io.IOException;
10+
import java.text.DateFormat;
11+
import java.text.SimpleDateFormat;
1012
import java.time.LocalDate;
1113
import java.util.Date;
1214
import java.util.HashMap;
@@ -17,14 +19,18 @@
1719

1820
public class RunningJobs {
1921

20-
public static void main(String[] args) throws IOException {
22+
static DateFormat timeFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
23+
// static String repo = "keycloak/keycloak";
24+
static String repo = "cncf/keycloak-testing";
25+
static int wait = 1;
2126

22-
// String repo = "cncf/keycloak-testing";
23-
String repo = "keycloak/keycloak";
27+
static String[] types = new String[] { "ubuntu-latest", "windows-latest" };
2428

29+
public static void main(String[] args) throws IOException {
2530
GitHub gitHub = Client.getInstance().gitHub();
2631

27-
System.out.format("%-40s %-30s %-10s %-10s\n", "Date", "Runner", "Running", "Queued");
32+
// System.out.println("Time,Runner,Running,Queued");
33+
System.out.format("%-20s %-30s %-10s %-10s\n", "Date", "Runner", "Running", "Queued");
2834

2935
while (true) {
3036
Map<String, Integer> queued = new HashMap<>();
@@ -57,12 +63,14 @@ public static void main(String[] args) throws IOException {
5763
runners.addAll(queued.keySet());
5864
runners.addAll(running.keySet());
5965

66+
Date date = new Date();
67+
6068
for (String r : runners) {
61-
System.out.format("%-40s %-30s %-10s %-10s\n", new Date(), r, running.get(r), queued.get(r));
69+
System.out.format("%-20s %-30s %-10s %-10s\n", timeFormatter.format(date), r, running.get(r), queued.get(r));
6270
}
6371

6472
try {
65-
Thread.sleep(TimeUnit.MINUTES.toMillis(1));
73+
Thread.sleep(TimeUnit.MINUTES.toMillis(wait));
6674
} catch (InterruptedException e) {
6775
throw new RuntimeException(e);
6876
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
curl -X POST \
4+
-d grant_type=client_credentials \
5+
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
6+
-d client-assertion-type=jwt-bearer \
7+
-d client_assertion="$1" \
8+
http://localhost:8080/realms/spiffe/protocol/openid-connect/token
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
BASIC=$(echo -n "$1:$2" | base64)
4+
5+
curl -X POST \
6+
-d grant_type=client_credentials \
7+
-H "Authorization: Basic $BASIC" \
8+
http://localhost:8080/realms/spiffe/protocol/openid-connect/token
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"issuer":"http://localhost/realms/master","authorization_endpoint":"http://localhost/realms/master/protocol/openid-connect/auth","token_endpoint":"http://localhost/realms/master/protocol/openid-connect/token","introspection_endpoint":"http://localhost/realms/master/protocol/openid-connect/token/introspect","userinfo_endpoint":"http://localhost/realms/master/protocol/openid-connect/userinfo","end_session_endpoint":"http://localhost/realms/master/protocol/openid-connect/logout","frontchannel_logout_session_supported":true,"frontchannel_logout_supported":true,"jwks_uri":"http://localhost/realms/master/protocol/openid-connect/certs","check_session_iframe":"http://localhost/realms/master/protocol/openid-connect/login-status-iframe.html","grant_types_supported":["authorization_code","client_credentials","implicit","password","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:token-exchange","urn:ietf:params:oauth:grant-type:uma-ticket","urn:openid:params:grant-type:ciba"],"acr_values_supported":["0","1"],"response_types_supported":["code","none","id_token","token","id_token token","code id_token","code token","code id_token token"],"subject_types_supported":["public","pairwise"],"prompt_values_supported":["none","login","consent"],"id_token_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512"],"id_token_encryption_alg_values_supported":["ECDH-ES+A256KW","ECDH-ES+A192KW","ECDH-ES+A128KW","RSA-OAEP","RSA-OAEP-256","RSA1_5","ECDH-ES"],"id_token_encryption_enc_values_supported":["A256GCM","A192GCM","A128GCM","A128CBC-HS256","A192CBC-HS384","A256CBC-HS512"],"userinfo_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512","none"],"userinfo_encryption_alg_values_supported":["ECDH-ES+A256KW","ECDH-ES+A192KW","ECDH-ES+A128KW","RSA-OAEP","RSA-OAEP-256","RSA1_5","ECDH-ES"],"userinfo_encryption_enc_values_supported":["A256GCM","A192GCM","A128GCM","A128CBC-HS256","A192CBC-HS384","A256CBC-HS512"],"request_object_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512","none"],"request_object_encryption_alg_values_supported":["ECDH-ES+A256KW","ECDH-ES+A192KW","ECDH-ES+A128KW","RSA-OAEP","RSA-OAEP-256","RSA1_5","ECDH-ES"],"request_object_encryption_enc_values_supported":["A256GCM","A192GCM","A128GCM","A128CBC-HS256","A192CBC-HS384","A256CBC-HS512"],"response_modes_supported":["query","fragment","form_post","query.jwt","fragment.jwt","form_post.jwt","jwt"],"registration_endpoint":"http://localhost/realms/master/clients-registrations/openid-connect","token_endpoint_auth_methods_supported":["private_key_jwt","client_secret_basic","client_secret_post","tls_client_auth","client_secret_jwt"],"token_endpoint_auth_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512"],"introspection_endpoint_auth_methods_supported":["private_key_jwt","client_secret_basic","client_secret_post","tls_client_auth","client_secret_jwt"],"introspection_endpoint_auth_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512"],"authorization_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512"],"authorization_encryption_alg_values_supported":["ECDH-ES+A256KW","ECDH-ES+A192KW","ECDH-ES+A128KW","RSA-OAEP","RSA-OAEP-256","RSA1_5","ECDH-ES"],"authorization_encryption_enc_values_supported":["A256GCM","A192GCM","A128GCM","A128CBC-HS256","A192CBC-HS384","A256CBC-HS512"],"claims_supported":["iss","sub","aud","exp","iat","auth_time","name","given_name","family_name","preferred_username","email","acr","azp","nonce"],"claim_types_supported":["normal"],"claims_parameter_supported":true,"scopes_supported":["openid","microprofile-jwt","basic","organization","phone","roles","acr","service_account","profile","web-origins","email","offline_access","address"],"request_parameter_supported":true,"request_uri_parameter_supported":true,"require_request_uri_registration":true,"code_challenge_methods_supported":["plain","S256"],"tls_client_certificate_bound_access_tokens":true,"revocation_endpoint":"http://localhost/realms/master/protocol/openid-connect/revoke","revocation_endpoint_auth_methods_supported":["private_key_jwt","client_secret_basic","client_secret_post","tls_client_auth","client_secret_jwt"],"revocation_endpoint_auth_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","HS256","HS512","ES256","RS256","HS384","ES512","PS256","PS512","RS512"],"backchannel_logout_supported":true,"backchannel_logout_session_supported":true,"device_authorization_endpoint":"http://localhost/realms/master/protocol/openid-connect/auth/device","backchannel_token_delivery_modes_supported":["poll","ping"],"backchannel_authentication_endpoint":"http://localhost/realms/master/protocol/openid-connect/ext/ciba/auth","backchannel_authentication_request_signing_alg_values_supported":["PS384","RS384","EdDSA","ES384","ES256","RS256","ES512","PS256","PS512","RS512"],"require_pushed_authorization_requests":false,"pushed_authorization_request_endpoint":"http://localhost/realms/master/protocol/openid-connect/ext/par/request","mtls_endpoint_aliases":{"token_endpoint":"http://localhost/realms/master/protocol/openid-connect/token","revocation_endpoint":"http://localhost/realms/master/protocol/openid-connect/revoke","introspection_endpoint":"http://localhost/realms/master/protocol/openid-connect/token/introspect","device_authorization_endpoint":"http://localhost/realms/master/protocol/openid-connect/auth/device","registration_endpoint":"http://localhost/realms/master/clients-registrations/openid-connect","userinfo_endpoint":"http://localhost/realms/master/protocol/openid-connect/userinfo","pushed_authorization_request_endpoint":"http://localhost/realms/master/protocol/openid-connect/ext/par/request","backchannel_authentication_endpoint":"http://localhost/realms/master/protocol/openid-connect/ext/ciba/auth"},"authorization_response_iss_parameter_supported":true}

kc-ext/spiffe-authenticator/retrieve-jwt-svid.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
cd target/tmp/spire
44

5-
OUTPUT=$(bin/spire-agent api fetch jwt -audience spiffe://example.org/myclient -output json)
5+
OUTPUT=$(bin/spire-agent api fetch jwt -audience http://localhost:8080/realms/spiffe -output json)
66

77
TOKEN=$(echo $OUTPUT | jq .[0].svids.[0].svid -r)
88
KEYS=$(echo $OUTPUT | jq '.[1].bundles."spiffe://example.org"' -r)
99

1010
echo $KEYS | base64 --decode > keys.json
1111

12-
echo $TOKEN
12+
echo $TOKEN

kc-ext/spiffe-authenticator/server.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ server {
77
log_level = "DEBUG"
88
ca_ttl = "168h"
99
default_x509_svid_ttl = "48h"
10+
11+
federation {
12+
bundle_endpoint {
13+
address = "0.0.0.0"
14+
port = 8543
15+
acme {
16+
domain_name = "example.org"
17+
email = "admin@example.org"
18+
}
19+
}
20+
}
1021
}
1122

1223
plugins {

0 commit comments

Comments
 (0)