Skip to content

Commit

Permalink
Update test for pki ca-user-show
Browse files Browse the repository at this point in the history
The basic CA test has been updated to run pki ca-user-show
with default API and API v2 then verify the access logs
generated by these commands.

The AccountClient has been updated to use the API version
from PKIClient.

The AccountServlet.logout() has been updated to return
NO_CONTENT status for consistency with API v1.
  • Loading branch information
edewata committed Oct 3, 2024
1 parent d474d83 commit 51aefab
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
41 changes: 40 additions & 1 deletion .github/workflows/ca-basic-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,52 @@ jobs:
diff expected output
- name: Test CA admin
- name: Check pki ca-user-show with default API
run: |
docker exec pki pki pkcs12-import \
--pkcs12 /root/.dogtag/pki-tomcat/ca_admin_cert.p12 \
--pkcs12-password Secret.123
docker exec pki pki -n caadmin ca-user-show caadmin
# check HTTP methods, paths, protocols, status, and authenticated users
docker exec pki find /var/log/pki/pki-tomcat \
-name "localhost_access_log.*" \
-exec cat {} \; \
| tail -4 \
| sed -e 's/^.* .* \(.*\) \[.*\] "\(.*\)" \(.*\) .*$/\2 \3 \1/' \
| tee output
cat > expected << EOF
GET /pki/v1/info HTTP/1.1 200 -
GET /ca/v1/account/login HTTP/1.1 200 caadmin
GET /ca/v1/admin/users/caadmin HTTP/1.1 200 caadmin
GET /ca/v1/account/logout HTTP/1.1 204 caadmin
EOF
diff expected output
- name: Check pki ca-user-show with API v2
run: |
docker exec pki pki -n caadmin --api v2 ca-user-show caadmin
# check HTTP methods, paths, protocols, status, and authenticated users
docker exec pki find /var/log/pki/pki-tomcat \
-name "localhost_access_log.*" \
-exec cat {} \; \
| tail -4 \
| sed -e 's/^.* .* \(.*\) \[.*\] "\(.*\)" \(.*\) .*$/\2 \3 \1/' \
| tee output
cat > expected << EOF
GET /pki/v2/info HTTP/1.1 200 -
GET /ca/v2/account/login HTTP/1.1 200 caadmin
GET /ca/v2/admin/users/caadmin HTTP/1.1 200 caadmin
GET /ca/v2/account/logout HTTP/1.1 204 caadmin
EOF
diff expected output
- name: Check cert requests in CA
run: |
docker exec pki pki -n caadmin ca-cert-request-find
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AccountClient extends Client {
public boolean loggedIn;

public AccountClient(PKIClient client, String subsystem) throws Exception {
super(client, subsystem, null, "account");
super(client, subsystem, "account");
}

public AccountClient(PKIClient client, String subsystem, String prefix) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public SubsystemClient(PKIClient client, String name) throws Exception {
// subsystem name should match the client name
super(client, name, name);

accountClient = new AccountClient(client, name, "rest");
accountClient = new AccountClient(client, name);
addClient(accountClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ public void logout(HttpServletRequest request, HttpServletResponse response) thr
logger.info("AccountServlet: Destroying session {}", session.getId());
session.invalidate();
}
response.sendError(HttpServletResponse.SC_NO_CONTENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void execute(String[] args) throws Exception {
if (subsystem == null) subsystem = defaultSubsystem;

PKIClient client = module.getClient();
accountClient = new AccountClient(client, subsystem, "rest");
accountClient = new AccountClient(client, subsystem);
accountClient.login();
}

Expand Down

0 comments on commit 51aefab

Please sign in to comment.