Skip to content

Commit

Permalink
LRCI-3470 Add ability to startup the OAuth2 Application
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhashimoto authored and brianchandotcom committed Apr 14, 2023
1 parent 4b7f593 commit ae110f3
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
105 changes: 105 additions & 0 deletions build-test-oauth2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,109 @@
todir="${liferay.home}/osgi/configs"
/>
</target>

<target depends="setup-yarn" name="start-oauth2-application">
<property location="${project.dir}/oauth2" name="oauth2.application.dir" />

<basename file="${oauth2.application.url}" property="oauth2.application.file.name" />

<trycatch>
<try>
<mirrors-get
dest="${oauth2.application.dir}/${oauth2.application.file.name}"
src="${oauth2.application.url}"
/>
</try>
<catch>
<mkdir dir="${oauth2.application.dir}" />

<execute dir="${oauth2.application.dir}">
curl ${oauth2.application.url} --output ${oauth2.application.file.name}
</execute>

<propertyregex
input="${oauth2.application.url}"
property="oauth2.application.mirrors.dir"
regexp="https?://(mirrors[^/]+/)?(.+)/[^/]+"
replace="\2"
/>

<mkdir dir="${mirrors.cache.dir}/${oauth2.application.mirrors.dir}" />

<copy
file="${oauth2.application.dir}/${oauth2.application.file.name}"
tofile="${mirrors.cache.dir}/${oauth2.application.mirrors.dir}/${oauth2.application.file.name}"
/>
</catch>
</trycatch>

<decompress
dest="${oauth2.application.dir}"
src="${oauth2.application.dir}/${oauth2.application.file.name}"
/>

<delete file="${oauth2.application.dir}/${oauth2.application.file.name}" />

<parallel>
<daemons>
<sequential>
<local name="start.oauth2.bash.file" />

<property location="start_oauth2.sh" name="start.oauth2.bash.file" />

<echo file="${start.oauth2.bash.file}">
<![CDATA[
#!/bin/bash
export PATH="${node.home}/bin:${node.home}/lib/node_modules/corepack/shims:${env.PATH}"
${npx.exec} serve -s ${oauth2.application.dir}/liferay-${oauth2.application.zip.id}/${oauth2.application.zip.id}-custom-element/build
]]>
</echo>

<exec executable="/bin/bash">
<arg line="${start.oauth2.bash.file}" />
</exec>

<delete file="${start.oauth2.bash.file}" />
</sequential>
</daemons>

<waitfor checkevery="5" checkeveryunit="second" maxwait="5" maxwaitunit="minute" timeoutproperty="wait.for.oauth2">
<http url="http://localhost:3000" />
</waitfor>
</parallel>
</target>

<target name="stop-oauth2-application">
<if>
<os family="unix" />
<then>
<local name="stop.oauth2.bash.file" />

<property location="stop_oauth2.sh" name="stop.oauth2.bash.file" />

<echo file="${stop.oauth2.bash.file}">
<![CDATA[
#!/bin/bash
ps -o pid,args -e | grep npx | grep liferay-${oauth2.application.zip.id} | grep -v grep
for i in `ps -o pid,args -e | grep npx | grep liferay-${oauth2.application.zip.id} | grep -v grep | cut -c1-5`
do
echo "Killing $i"
kill -9 $i
done
]]>
</echo>

<exec executable="/bin/bash">
<arg line="${stop.oauth2.bash.file}" />
</exec>

<delete file="${stop.oauth2.bash.file}" />
</then>
</if>
</target>
</project>
18 changes: 18 additions & 0 deletions build-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15542,6 +15542,15 @@ mail.send.blacklist=</echo>
</then>
</if>

<get-testcase-property property.name="oauth2.application.enabled" />

<if>
<equals arg1="${oauth2.application.enabled}" arg2="true" />
<then>
<ant antfile="build-test-oauth2.xml" target="start-oauth2-application" />
</then>
</if>

<if>
<isset property="workspace.name" />
<then>
Expand All @@ -15560,6 +15569,15 @@ mail.send.blacklist=</echo>
</then>
</if>

<get-testcase-property property.name="oauth2.application.enabled" />

<if>
<equals arg1="${oauth2.application.enabled}" arg2="true" />
<then>
<ant antfile="build-test-oauth2.xml" target="stop-oauth2-application" />
</then>
</if>

<if>
<isset property="workspace.name" />
<then>
Expand Down
17 changes: 17 additions & 0 deletions test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,22 @@

modules.includes.public[service-builder-jdk8]=${modules.includes[service-builder-jdk8]}

##
## Node
##

node.exec=${project.dir}/build/node/bin/node
node.home=${project.dir}/build/node
npx.exec=${project.dir}/build/node/lib/node_modules/corepack/shims/npx
yarn.exec=${project.dir}/build/node/lib/node_modules/corepack/shims/yarn

##
## OAuth 2
##

oauth2.application.url=https://resources.learn.liferay.com/dxp/latest/en/headless-delivery/using-oauth2/liferay-${oauth2.application.zip.id}.zip
oauth2.application.zip.id=c2b6

##
## OneDrive
##
Expand Down Expand Up @@ -10078,6 +10094,7 @@
marketplace.app.acceptance,\
marketplace.staging.enabled,\
minimum.slave.ram,\
oauth2.application.enabled,\
openam.enabled,\
operating.system.types,\
osgi.app.includes,\
Expand Down

0 comments on commit ae110f3

Please sign in to comment.