Skip to content

Commit

Permalink
chore(ResponseTest.java): Updated contents of string for CommandPlain…
Browse files Browse the repository at this point in the history
…Secure test.
  • Loading branch information
AsifNawaz-cnic committed Nov 9, 2023
1 parent b74cb8d commit 459c6d0
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 35 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// .devcontainer/devcontainer.json
{
"name": "Java",
"image": "mcr.microsoft.com/devcontainers/java",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
},
"extensions": [
"vscjava.vscode-java-pack"
]
}
}
14 changes: 8 additions & 6 deletions .github/workflows/auto-merge-dependabot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ on:
- opened
- synchronize

permissions:
contents: write
pull-requests: write

jobs:
tests:
uses: ./.github/workflows/test.yml
secrets: inherit

permissions:
contents: read

dependabot:
name: Auto-merge Dependabot PR
runs-on: ubuntu-latest
runs-on: ${{ vars.RTLDEV_MW_CI_OS }}
needs: tests
permissions:
contents: write
pull-requests: write

if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ on:
- master

jobs:
build:
name: Build
tests:
uses: ./.github/workflows/test.yml

secrets: inherit
permissions:
contents: read

release:
name: Release @ ubuntu-latest
runs-on: ubuntu-latest
needs: build
name: Release @ ${{ vars.RTLDEV_MW_CI_OS }}
runs-on: ${{ vars.RTLDEV_MW_CI_OS }}
needs: tests
permissions:
contents: write
issues: write
deployments: write

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -44,14 +51,14 @@ jobs:
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
MAVEN_OPTS: ${{ vars.MAVEN_OPTS }}
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}
ENCRYPTED_C9F9AEDF26B7_KEY: ${{ secrets.ENCRYPTED_C9F9AEDF26B7_KEY }}
ENCRYPTED_C9F9AEDF26B7_IV: ${{ secrets.ENCRYPTED_C9F9AEDF26B7_IV }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.RTLDEV_MW_CI_TOKEN }}
RTLDEV_MW_NOTIFICATION_URI: ${{ secrets.RTLDEV_MW_NOTIFICATION_URI }}
run: |
openssl aes-256-cbc -K $ENCRYPTED_C9F9AEDF26B7_KEY -iv $ENCRYPTED_C9F9AEDF26B7_IV -in codesigning.asc.enc -out codesigning.asc -d
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
# as the build names above change each time Node versions change
lint:
name: 🧪 Linting
runs-on: ubuntu-latest
runs-on: ${{ vars.RTLDEV_MW_CI_OS }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -26,7 +28,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test_matrix:
runs-on: ubuntu-latest
runs-on: ${{ vars.RTLDEV_MW_CI_OS }}
permissions:
contents: read

strategy:
matrix:
Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
<version>3.6.2</version>
<configuration>
<verbose>true</verbose>
<source>8</source>
<additionalOptions>-html5</additionalOptions>
</configuration>
<executions>
Expand Down Expand Up @@ -123,6 +122,11 @@
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.4.5</version> <!-- Use the desired version -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down
45 changes: 27 additions & 18 deletions src/main/java/net/hexonet/apiconnector/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
* Response covers all functionality to wrap a Backend API Response like accessing data
* Response covers all functionality to wrap a Backend API Response like
* accessing data
*
* @author Kai Schwarz
* @version %I%, %G%
Expand All @@ -23,7 +25,8 @@ public class Response {
*/
private Map<String, String> command;
/**
* Column names available in this responsse NOTE: this includes also FIRST, LAST, LIMIT, COUNT,
* Column names available in this responsse NOTE: this includes also FIRST,
* LAST, LIMIT, COUNT,
* TOTAL and maybe further specific columns in case of a list query
*/
private ArrayList<String> columnkeys;
Expand Down Expand Up @@ -173,7 +176,8 @@ public double getRuntime() {
}

/**
* Check if current API response represents an error case API response code is an 5xx code
* Check if current API response represents an error case API response code is
* an 5xx code
*
* @return boolean result
*/
Expand All @@ -183,7 +187,8 @@ public boolean isError() {
}

/**
* Check if current API response represents a success case API response code is an 2xx code
* Check if current API response represents a success case API response code is
* an 2xx code
*
* @return boolean result
*/
Expand All @@ -193,7 +198,8 @@ public boolean isSuccess() {
}

/**
* Check if current API response represents a temporary error case API response code is an 4xx
* Check if current API response represents a temporary error case API response
* code is an 4xx
* code
*
* @return boolean result
Expand Down Expand Up @@ -302,16 +308,15 @@ public Map<String, String> getCommand() {
* @return plain text command
*/
public String getCommandPlain() {
StringBuilder tmp = new StringBuilder("");
Iterator<Map.Entry<String, String>> it = this.command.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pair = it.next();
tmp.append(pair.getKey());
tmp.append(" = ");
tmp.append(pair.getValue());
tmp.append("\n");
StringBuilder result = new StringBuilder();
List<Map.Entry<String, String>> sortedEntries = new ArrayList<>(this.command.entrySet());
sortedEntries.sort(Map.Entry.comparingByKey());

for (Map.Entry<String, String> entry : sortedEntries) {
result.append(entry.getKey()).append(" = ").append(entry.getValue()).append("\n");
}
return tmp.toString();

return result.toString();
}

/**
Expand Down Expand Up @@ -536,7 +541,8 @@ public int getRecordsTotalCount() {
}

/**
* Get limit(ation) setting of the current list query This is the count of requested rows
* Get limit(ation) setting of the current list query This is the count of
* requested rows
*
* @return limit setting or count requested rows
*/
Expand Down Expand Up @@ -598,7 +604,8 @@ private boolean hasColumn(String key) {
}

/**
* Check if the record list contains a record for the current record index in use
* Check if the record list contains a record for the current record index in
* use
*
* @return boolean result
*/
Expand All @@ -608,7 +615,8 @@ private boolean hasCurrentRecord() {
}

/**
* Check if the record list contains a next record for the current record index in use
* Check if the record list contains a next record for the current record index
* in use
*
* @return boolean result
*/
Expand All @@ -618,7 +626,8 @@ private boolean hasNextRecord() {
}

/**
* Check if the record list contains a previous record for the current record index in use
* Check if the record list contains a previous record for the current record
* index in use
*
* @return boolean result
*/
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/hexonet/apiconnector/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void getCommandPlainSecure() {
cmd.put("SUBUSER", "test.user");
cmd.put("PASSWORD", "test.passw0rd");
Response r = new Response("", cmd);
String str = "SUBUSER = test.user\nCOMMAND = CheckAuthentication\nPASSWORD = ***\n";
String str = "COMMAND = CheckAuthentication\nPASSWORD = ***\nSUBUSER = test.user\n";
assertEquals(str, r.getCommandPlain());
}

Expand Down

0 comments on commit 459c6d0

Please sign in to comment.