-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from equinix-labs/modifyFlows
- Loading branch information
Showing
387 changed files
with
1,971 additions
and
24,244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,34 +10,52 @@ on: | |
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TEST_DATA_UAT_QINQ_PORT: ${{ secrets.TEST_DATA_UAT_QINQ_PORT }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: maven | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Commit to branch if client is updated after executing make. | ||
run: | | ||
git config --global user.name 'equinix-labs@auto-commit-workflow' | ||
git config --global user.email '[email protected]' | ||
git config advice.addIgnoredFile false | ||
git fetch | ||
echo -e "\nThis is executing for branch: ${GITHUB_REF##*/}." | ||
git checkout ${GITHUB_REF##*/} | ||
make generate | ||
echo -e "Make execution completed." | ||
git add equinix-openapi-fabric/. | ||
echo -e "\nGit status:" | ||
echo `git status` | ||
cdate=`date` | ||
cmsg="Auto commit generated client changes - $cdate" | ||
echo -e "\nCommit message created : $cmsg" | ||
echo -e "\nCommitting if there are files to update in client dir:" | ||
echo `git commit -m "$cmsg"` | ||
echo `git push` | ||
- name: Set git user and generate files | ||
run: | | ||
git config --global user.name 'equinix-labs@auto-commit-workflow' | ||
git config --global user.email '[email protected]' | ||
git config advice.addIgnoredFile false | ||
git fetch | ||
echo -e "\nThis is executing for branch: ${GITHUB_REF##*/}." | ||
git checkout ${GITHUB_REF##*/} | ||
make generate | ||
- name: Tests | ||
env: | ||
TEST_HOST_URL: https://uatapi.equinix.com | ||
CLIENT_ID: ${{ secrets.TEST_USER_CLIENT_ID }} | ||
CLIENT_SECRET: ${{ secrets.TEST_USER_CLIENT_SECRET }} | ||
TEST_USER_NAME: ${{ secrets.TEST_USER_NAME }} | ||
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} | ||
shell: bash | ||
working-directory: ./equinix-openapi-fabric | ||
run: |- | ||
mvn clean package -DenvUrl=${{ env.TEST_HOST_URL }} -DuserName=${{ env.TEST_USER_NAME }} \ | ||
-DuserPassword=${{ env.TEST_USER_PASSWORD }} -DclientId=${{ env.CLIENT_ID }} -DclientSecret=${{ env.CLIENT_SECRET }} | ||
- name: Commit to branch. | ||
run: | | ||
git add . | ||
echo -e "\nGit status:" | ||
echo `git status` | ||
cdate=`date` | ||
cmsg="Auto commit generated client changes - $cdate" | ||
echo -e "\nCommit message created : $cmsg" | ||
echo -e "\nCommitting if there are files to update in client dir:" | ||
echo `git commit -m "$cmsg"` | ||
echo `git push` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
equinix-openapi-fabric/src/test/java/com/equinix/openapi/fabric/v4/api/AbstractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.equinix.openapi.fabric.v4.api; | ||
|
||
import com.equinix.openapi.fabric.ApiClient; | ||
import com.equinix.openapi.fabric.ApiException; | ||
import com.equinix.openapi.fabric.Configuration; | ||
import com.equinix.openapi.fabric.Pair; | ||
import com.equinix.openapi.fabric.v4.api.dto.TokenRequestDto; | ||
import com.equinix.openapi.fabric.v4.api.dto.TokenResponseDto; | ||
import com.equinix.openapi.fabric.v4.api.dto.port.PortDto; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.Type; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public abstract class AbstractTest { | ||
public ApiClient generateToken() { | ||
ApiClient apiTokeClient = Configuration.getDefaultApiClient(); | ||
|
||
TokenRequestDto tokenRequestDto = new TokenRequestDto() | ||
.setClientId(System.getProperty("clientId")) | ||
.setClientSecret(System.getProperty("clientSecret")) | ||
.setUserPassword(System.getProperty("userPassword")) | ||
.setUserName(System.getProperty("userName")); | ||
|
||
String localVarPath = "/oauth2/v1/token"; | ||
|
||
List<Pair> localVarQueryParams = new ArrayList<Pair>(); | ||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); | ||
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); | ||
Map<String, String> localVarCookieParams = new HashMap<String, String>(); | ||
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); | ||
|
||
localVarHeaderParams.put("Content-Type", "application/json"); | ||
String[] localVarAuthNames = new String[]{"BearerAuth"}; | ||
|
||
okhttp3.Call call; | ||
TokenResponseDto tokenResponseDto = null; | ||
|
||
try { | ||
call = apiTokeClient.buildCall(apiTokeClient.getBasePath(), localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, | ||
tokenRequestDto, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, null); | ||
|
||
Type localVarReturnType = new TypeToken<TokenResponseDto>() { | ||
}.getType(); | ||
tokenResponseDto = (TokenResponseDto) apiTokeClient.execute(call, localVarReturnType).getData(); | ||
} catch (ApiException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
ApiClient apiClient = Configuration.getDefaultApiClient(); | ||
apiClient.addDefaultHeader("Authorization", "Bearer " + tokenResponseDto.getAccessToken()); | ||
|
||
return apiClient; | ||
} | ||
|
||
protected PortDto getPort(EnvVariable envVariable) { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
String json = System.getenv(envVariable.value); | ||
try { | ||
return mapper.readValue(json, PortDto.class); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
protected void printJson(Object object) { | ||
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); | ||
try { | ||
String json = ow.writeValueAsString(object); | ||
System.out.println(json); | ||
} catch ( | ||
JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public enum EnvVariable { | ||
QINQ_PORT("TEST_DATA_UAT_QINQ_PORT"); | ||
|
||
private String value; | ||
|
||
EnvVariable(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
} | ||
} |
Oops, something went wrong.