diff --git a/Jenkinsfile b/Jenkinsfile index 3e22f2b..f0fe62c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,32 +50,32 @@ pipeline { def remote = [ name : 'HostServer', host : '192.168.0.216', - user : '$JOBLINK_LOCAL_USER', - password : '$JOBLINK_LOCAL_PASSWD', + user : '${env.JOBLINK_LOCAL_USER}', + password : '${env.JOBLINK_LOCAL_PASSWD}', allowAnyHosts: true, ] if (env.BRANCH_NAME == 'main') { - sshRemove(path: '/home/$JOBLINK_LOCAL_USER/builds/main/linux', remote: remote) - sshCommand remote: remote, command: "mkdir /home/$JOBLINK_LOCAL_USER/builds/main/linux" - sshPut(from: 'build/linux/x64/release', into: '/home/$JOBLINK_LOCAL_USER/builds/main/linux', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_LOCAL_USER/builds/main/linux/release/* /home/$JOBLINK_LOCAL_USER/builds/main/linux" - sshCommand remote: remote, command: "rm -R /home/$JOBLINK_LOCAL_USER/builds/main/linux/release/" - sshRemove(path: '/home/$JOBLINK_LOCAL_USER/builds/main/apk', remote: remote) - sshCommand remote: remote, command: "mkdir /home/$JOBLINK_LOCAL_USER/builds/main/apk" - sshPut(from: 'build/app/outputs/apk/release', into: '/home/$JOBLINK_LOCAL_USER/builds/main/apk', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_LOCAL_USER/builds/main/apk/release/* /home/$JOBLINK_LOCAL_USER/builds/main/apk" - sshCommand remote: remote, command: "rm -R /home/$JOBLINK_LOCAL_USER/builds/main/apk/release/" + sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote) + sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux" + sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux" + sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/" + sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote) + sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk" + sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk" + sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/" } else { - sshRemove(path: '/home/$JOBLINK_LOCAL_USER/builds/dev/linux', remote: remote) - sshCommand remote: remote, command: "mkdir /home/$JOBLINK_LOCAL_USER/builds/dev/linux" - sshPut(from: 'build/linux/x64/release', into: '/home/$JOBLINK_LOCAL_USER/builds/dev/linux', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_LOCAL_USER/builds/dev/linux/release/* /home/$JOBLINK_LOCAL_USER/builds/dev/linux" - sshCommand remote: remote, command: "rm -R /home/$JOBLINK_LOCAL_USER/builds/dev/linux/release/" - sshRemove(path: '/home/$JOBLINK_LOCAL_USER/builds/dev/apk', remote: remote) - sshCommand remote: remote, command: "mkdir /home/$JOBLINK_LOCAL_USER/builds/dev/apk" - sshPut(from: 'build/app/outputs/apk/release', into: '/home/$JOBLINK_LOCAL_USER/builds/dev/apk', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_LOCAL_USER/builds/dev/apk/release/* /home/$JOBLINK_LOCAL_USER/builds/dev/apk" - sshCommand remote: remote, command: "rm -R /home/$JOBLINK_LOCAL_USER/builds/dev/apk/release/" + sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote) + sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux" + sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux" + sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/" + sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote) + sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk" + sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk" + sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/" } } } @@ -92,14 +92,14 @@ pipeline { name : 'MarinoDev', host : 'marinodev.com', port : 21098, - user : '$JOBLINK_REMOTE_USER', + user : '${env.JOBLINK_REMOTE_USER}', identityFile : '/var/jenkins_home/marinoDevPrivateKey', - passphrase : '$JOBLINK_REMOTE_PASSWD', + passphrase : '${env.JOBLINK_REMOTE_PASSWD}', allowAnyHosts: true, ] - sshRemove(path: '/home/$JOBLINK_REMOTE_USER/public_html/fbla', remote: remote) - sshPut(from: '/var/jenkins_home/workspace/fbla-ui_main/build/web/', into: '/home/$JOBLINK_REMOTE_USER/public_html/', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_REMOTE_USER/public_html/web /home/$JOBLINK_REMOTE_USER/public_html/fbla" + sshRemove(path: '/home/${env.JOBLINK_REMOTE_USER}/public_html/fbla', remote: remote) + sshPut(from: '/var/jenkins_home/workspace/fbla-ui_main/build/web/', into: '/home/${env.JOBLINK_REMOTE_USER}/public_html/', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_REMOTE_USER}/public_html/web /home/${env.JOBLINK_REMOTE_USER}/public_html/fbla" } } } @@ -109,14 +109,13 @@ pipeline { def remote = [ name : 'HostServer', host : '192.168.0.216', - user : '$JOBLINK_LOCAL_USER', - password : '$JOBLINK_LOCAL_PASSWD', + user : "${env.JOBLINK_LOCAL_USER}", + password : "${env.JOBLINK_LOCAL_PASSWD}", allowAnyHosts: true, ] - sh 'echo $JOBLINK_LOCAL_USER $JOBLINK_LOCAL_PASSWD' - sshRemove(path: '/home/$JOBLINK_LOCAL_USER/fbla-webserver/webfiles/fbla', remote: remote) - sshPut(from: 'build/web/', into: '/home/$JOBLINK_LOCAL_USER/fbla-webserver', remote: remote) - sshCommand remote: remote, command: "mv /home/$JOBLINK_LOCAL_USER/fbla-webserver/web /home/$JOBLINK_LOCAL_USER/fbla-webserver/webfiles/fbla" + sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla', remote: remote) + sshPut(from: 'build/web/', into: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver', remote: remote) + sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/web /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla" } } } diff --git a/fbla-api/test/fbla_api_test.dart b/fbla-api/test/fbla_api_test.dart index 7005297..b9c78b6 100644 --- a/fbla-api/test/fbla_api_test.dart +++ b/fbla-api/test/fbla_api_test.dart @@ -1,18 +1,17 @@ import 'dart:convert'; -import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; -import 'package:fbla_api/fbla_api.dart'; -import 'package:test/test.dart'; -import 'package:http/http.dart' as http; import 'dart:io'; -final apiAddress = 'https://homelab.marinodev.com'; -SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!); +import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; +import 'package:fbla_api/fbla_api.dart'; +import 'package:http/http.dart' as http; +import 'package:test/test.dart'; -void main() async{ +final apiAddress = 'https://homelab.marinodev.com'; +SecretKey secretKey = SecretKey(Platform.environment['JOBLINK_SECRET_KEY']!); + +void main() async { final jwt = JWT( - { - 'username': 'tmp' - }, + {'username': 'tmp'}, ); final token = jwt.sign(secretKey); @@ -43,13 +42,14 @@ void main() async{ "password": "tmp" } '''; - var response = await http.post(Uri.parse('$apiAddress, /fbla-api/createuser'), + var response = await http.post( + Uri.parse('$apiAddress, /fbla-api/createuser'), body: json, headers: {'Authorization': token}).timeout(const Duration(seconds: 20)); expect(response.statusCode, 200); expect(response.body, 'tmp'); }); - test('sign-in', () async{ + test('sign-in', () async { var json = ''' { "username": "tmp", @@ -64,17 +64,15 @@ void main() async{ expect(response.statusCode, 200); expect(JWT.decode(response.body).payload['username'], 'tmp'); }); - test('delete-user', () async{ + test('delete-user', () async { var json = ''' { "username": "tmp" } '''; - var response = await http.post( - Uri.parse('$apiAddress/fbla-api/deleteuser'), + var response = await http.post(Uri.parse('$apiAddress/fbla-api/deleteuser'), body: json, - headers: {'Authorization': token}).timeout(const Duration(seconds: 20) - ); + headers: {'Authorization': token}).timeout(const Duration(seconds: 20)); expect(response.statusCode, 200); expect(response.body, 'tmp'); }); @@ -94,7 +92,8 @@ void main() async{ "locationAddress": "tmp" } '''; - var response = await http.post(Uri.parse('$apiAddress/fbla-api/createbusiness'), + var response = await http.post( + Uri.parse('$apiAddress/fbla-api/createbusiness'), body: json, headers: {'Authorization': token}).timeout(const Duration(seconds: 20));