diff --git a/docker-compose.yml b/docker-compose.yml index a90ecff..313827f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,20 @@ -version: '3' -services: - openldap: - # https://github.com/osixia/docker-openldap - # https://www.openldap.org - image: osixia/openldap:1.2.4 - environment: - LDAP_ORGANISATION: "IT Latinos NZ" - LDAP_DOMAIN: "latintech.org" - LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASS} - ports: - - 389:389 - - 636:636 - volumes: - - ./ldap:/var/lib/ldap - - ./ldap:/etc/ldap/slapd.d - webapp: - image: aleon1220/soa:latest - ports: - - 8080:8080 +version: '3' +services: + openldap: + # https://github.com/osixia/docker-openldap + # https://www.openldap.org + image: osixia/openldap:1.2.4 + environment: + LDAP_ORGANISATION: "IT Latinos NZ" + LDAP_DOMAIN: "latintech.org" + LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASS} + ports: + - 389:389 + - 636:636 + volumes: + - ./ldap:/var/lib/ldap + - ./ldap:/etc/ldap/slapd.d + webapp: + image: aleon1220/soa:latest + ports: + - 8080:8080 diff --git a/src/main/java/service/GenerateQRCode.java b/src/main/java/service/GenerateQRCode.java index fc03469..c4ec2c7 100644 --- a/src/main/java/service/GenerateQRCode.java +++ b/src/main/java/service/GenerateQRCode.java @@ -1,24 +1,23 @@ -package service; - -import java.io.IOException; -import java.nio.file.Paths; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatWriter; -import com.google.zxing.WriterException; -import com.google.zxing.client.j2se.MatrixToImageWriter; -import com.google.zxing.common.BitMatrix; - -public class GenerateQRCode { - - public void createWebsiteQRCode() throws WriterException, IOException { - String qrData = "www.andres.nz"; - String localPath = "/home/aleonrangel"; - boolean validateQR = false; - - BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null); - MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null); - System.out.println("QR code created"); - validateQR = true; - } -} +package service; + +import java.io.IOException; +import java.nio.file.Paths; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; + +public class GenerateQRCode { + public boolean validateQR = false; + + public void createWebsiteQRCode() throws WriterException, IOException { + String qrData = "www.andres.nz"; + String localPath = "/home/aleonrangel"; + BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null); + MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null); + System.out.println("QR code created"); + validateQR = true; + } +} diff --git a/src/test/java/auth/ldap/TestLDAPAuthentication.java b/src/test/java/auth/ldap/TestLDAPAuthentication.java index c6bcc70..f486e57 100644 --- a/src/test/java/auth/ldap/TestLDAPAuthentication.java +++ b/src/test/java/auth/ldap/TestLDAPAuthentication.java @@ -1,10 +1,15 @@ package auth.ldap; import org.junit.Test; -import org.mockito.Mockito; import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.mockito.Mockito; import com.unboundid.ldap.sdk.LDAPConnection; import com.unboundid.ldap.sdk.LDAPException; +import com.unboundid.ldap.sdk.LDAPSearchException; import com.unboundid.ldap.sdk.SearchRequest; import com.unboundid.ldap.sdk.SearchResult; import com.unboundid.ldap.sdk.SearchResultEntry; @@ -20,7 +25,7 @@ public class TestLDAPAuthentication { // - Verifies expected methods are called on the mocks @Test - public void testMockOpenLDAPAdminSearch() { + public void testMockOpenLDAPAdminSearch() throws LDAPSearchException { // Mock LDAPConnection LDAPConnection connectionMock = Mockito.mock(LDAPConnection.class); @@ -32,16 +37,21 @@ public void testMockOpenLDAPAdminSearch() { // Mock search result entries SearchResultEntry entry1 = Mockito.mock(SearchResultEntry.class); SearchResultEntry entry2 = Mockito.mock(SearchResultEntry.class); - + SearchResultEntry[] ldapResult = new SearchResultEntry[] { entry1, entry2 }; + List resultList = Arrays.asList(ldapResult); // Stub searchEntries to return mocked entries - Mockito.when(searchResultMock.getSearchEntries()).thenReturn(new SearchResultEntry[] { entry1, entry2 }); + Mockito.when(searchResultMock.getSearchEntries()).thenReturn(resultList); // Test the method AuthenticateOpenLDAP ldapAuth = new AuthenticateOpenLDAP(); ldapAuth.openLDAPAdminSearch(); // Verify search was called - Mockito.verify(connectionMock).search(Mockito.anyString(), Mockito.any(), Mockito.anyString()); + try { + Mockito.verify(connectionMock).search(Mockito.anyString(), Mockito.any(), Mockito.anyString()); + } catch (LDAPSearchException e) { + e.printStackTrace(); + } // Verify entry processing Mockito.verify(entry1).toLDIFString(); @@ -53,7 +63,6 @@ public void testMockOpenLDAPAdminSearch() { @Test public void testOpenLDAPAdminSearch_withOpenLDAP() { - // Test parameters String ldapURL = "ldap://localhost"; String ldapHost = "localhost"; @@ -61,7 +70,7 @@ public void testOpenLDAPAdminSearch_withOpenLDAP() { String bindDN = "cn=admin,dc=my-company,dc=com"; var bindPassword = "adminpassword"; String baseDN = "dc=my-company,dc=com"; - String searchFilter = "(objectClass=*)"; + String searchFilter = "(objectClass=*)"; // Connect to OpenLDAP // Establishing a connection to the LDAP server diff --git a/src/test/java/auth/login/LoginReply.java b/src/test/java/auth/login/LoginReply.java index 7f3d9b5..74142d4 100644 --- a/src/test/java/auth/login/LoginReply.java +++ b/src/test/java/auth/login/LoginReply.java @@ -35,6 +35,6 @@ public void setAuthenticationResult(AuthenticationResult authenticationResult) { public String toString() { // return getClass()+"challenge"+challengeParameters+"data in // authent"+authenticationResult.getIdToken(); - return getClass() + " Not obtaining really much"; + return getClass() + "JSON Overriding functionality"; } } diff --git a/src/test/java/json/TestConversionJSON2Object.java b/src/test/java/json/TestConversionJSON2Object.java index f2e23a5..6b9bc7a 100644 --- a/src/test/java/json/TestConversionJSON2Object.java +++ b/src/test/java/json/TestConversionJSON2Object.java @@ -1,4 +1,4 @@ -package attendance.gson; +package json; import com.google.gson.Gson; @@ -7,12 +7,7 @@ public class TestConversionJSON2Object { public static void main(String[] args) { - // TODO Auto-generated method stub: use a variable for the token - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7kNMUrb5tE4vTfG-kzctCq7YxU2FfJhDTR_feoRohcjWZp-Zyl2BYFjNXl42ZZEk-TlLHov73izA\",\"ExpiresIn\":3600,\"TokenType\":\"Bearer\",\"RefreshToken\":\"eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ.Wa12tUlCQHIjWvDx8BdhyQdftCwlFXb5W99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zxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - - String jsonInString = "{'name' : 'martina perumal'}"; - Gson gson = new Gson(); // Restaurant restaurantObject = gson.fromJson(restaurantJson, @@ -20,11 +15,7 @@ public static void main(String[] args) { LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); // Object loginReplyObject = gson.fromJson(replyJson, Object.class); - - Girl girl = gson.fromJson(jsonInString, Girl.class); - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); // System.out.println("obtain token "+ loginReplyObject.authenticationResult); } } diff --git a/src/test/java/json/TestConversionJson2Map.java b/src/test/java/json/TestConversionJson2Map.java index 1376f2e..3ac0ccb 100644 --- a/src/test/java/json/TestConversionJson2Map.java +++ b/src/test/java/json/TestConversionJson2Map.java @@ -10,6 +10,7 @@ public class TestConversionJson2Map { public void convertJSON2Map() { String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5h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wfv58EzP4R9UV1XFT2FufESkIfOhyM8ILwKKv3dilyrNs.hXpBG-_svaWFcmQvcxHuVA\",\"IdToken\":\"eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTA4NTg2OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; + String jsonInString = "{'name' : 'Alejandra Rangel'}"; Gson gson = new Gson(); Type authorization = new TypeToken>() { diff --git a/src/test/java/json/TestJSON2YAML.java b/src/test/java/json/TestJSON2YAML.java index 64acb2b..cbd5d0f 100644 --- a/src/test/java/json/TestJSON2YAML.java +++ b/src/test/java/json/TestJSON2YAML.java @@ -1,24 +1,67 @@ -package com.leo.json; +package json; import com.google.gson.Gson; +import org.yaml.snakeyaml.Yaml; +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.Map; public class TestJSON2YAML { - public static void main(String[] args) { - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7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1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - String jsonInString = "{'name' : 'martina perumal'}"; + // Test method to convert JSON to YAML + @Test + public void testJsonToYamlConversion() { + String jsonInput = "{\"name\":\"John\", \"age\":30}"; + Gson gson = new Gson(); + Yaml yaml = new Yaml(); + + // Convert JSON to a Map + Map map = gson.fromJson(jsonInput, Map.class); + + // Convert Map to YAML + String yamlOutput = yaml.dump(map); + + // Assert that YAML output is not null or empty + assertNotNull("YAML output should not be null", yamlOutput); + assertFalse("YAML output should not be empty", yamlOutput.isEmpty()); + } + + // Test method to convert YAML to JSON + @Test + public void testYamlToJsonConversion() { + String yamlInput = "name: John\nage: 30"; + Gson gson = new Gson(); + Yaml yaml = new Yaml(); + + // Convert YAML to a Map + Map map = yaml.load(yamlInput); + + // Convert Map to JSON + String jsonOutput = gson.toJson(map); + + // Assert that JSON output is not null or empty + assertNotNull("JSON output should not be null", jsonOutput); + assertFalse("JSON output should not be empty", jsonOutput.isEmpty()); + } + + // Test method to check if YAML output matches expected structure + @Test + public void testYamlStructure() { + String jsonInput = "{\"name\":\"John\", \"age\":30}"; Gson gson = new Gson(); + Yaml yaml = new Yaml(); - // Restaurant restaurantObject = gson.fromJson(restaurantJson, - // Restaurant.class); - LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + // Convert JSON to a Map + Map map = gson.fromJson(jsonInput, Map.class); - // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + // Convert Map to YAML + String yamlOutput = yaml.dump(map); - Girl girl = gson.fromJson(jsonInString, Girl.class); + // Expected YAML structure + String expectedYaml = "name: John\nage: 30\n"; - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); - // System.out.println("obtain token "+ loginReplyObject.authenticationResult); + // Assert that the YAML output matches the expected structure + assertEquals("YAML output should match the expected structure", expectedYaml, yamlOutput); } } diff --git a/src/test/java/json/TestJSONResponse.java b/src/test/java/json/TestJSONResponse.java deleted file mode 100644 index bd8499d..0000000 --- a/src/test/java/json/TestJSONResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -package json; - -import javax.json.Json; -import javax.json.stream.JsonParser; -import javax.json.stream.JsonParser.Event; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class TestJSONResponse { - - public static void main(String[] args) throws MalformedURLException { - // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); - // URL url = new - // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - - // try (InputStream is = url.openStream(); JsonParser parser = - // Json.createParser(is)) { - try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - JsonParser parser = (JsonParser) Json.createReader(br); - - while (parser.hasNext()) { - Event e = parser.next(); - if (e == Event.KEY_NAME) { - switch (parser.getString()) { - case "RefreshToken": - parser.next(); - System.out.print(parser.getString()); - System.out.print(": "); - break; - case "IdToken": - parser.next(); - System.out.println(parser.getString()); - System.out.println("---------"); - break; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/test/java/json/TestJSONToken.java b/src/test/java/json/TestJSONToken.java new file mode 100644 index 0000000..0fd72b1 --- /dev/null +++ b/src/test/java/json/TestJSONToken.java @@ -0,0 +1,82 @@ +package json; + +import javax.json.Json; +import javax.json.stream.JsonParser; +import javax.json.stream.JsonParser.Event; + +import org.junit.Test; + +import com.google.gson.Gson; + +import auth.login.LoginReply; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +public class TestJSONToken { + + @Test + public void testMalformedURL() throws MalformedURLException { + // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); + // URL url = new + // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + + // try (InputStream is = url.openStream(); JsonParser parser = + // Json.createParser(is)) { + try { + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + JsonParser parser = (JsonParser) Json.createReader(br); + + while (parser.hasNext()) { + Event e = parser.next(); + if (e == Event.KEY_NAME) { + switch (parser.getString()) { + case "RefreshToken": + parser.next(); + System.out.print(parser.getString()); + System.out.print(": "); + break; + case "IdToken": + parser.next(); + System.out.println(parser.getString()); + System.out.println("---------"); + break; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void formatTokenJSONResponse() { + String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7kNMUrb5tE4vTfG-kzctCq7YxU2FfJhDTR_feoRohcjWZp-Zyl2BYFjNXl42ZZEk-TlLHov73izA\",\"ExpiresIn\":3600,\"TokenType\":\"Bearer\",\"Refre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ImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; + Gson gson = new Gson(); + + // Restaurant restaurantObject = gson.fromJson(restaurantJson, + // Restaurant.class); + LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + + // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); + System.out.println("obtain token "+ loginReplyObject.getAuthenticationResult().getAccessToken()); + } +} diff --git a/src/test/java/utilities/TestQRFunctions.java b/src/test/java/utilities/TestQRFunctions.java index 52e5dd7..c984d83 100644 --- a/src/test/java/utilities/TestQRFunctions.java +++ b/src/test/java/utilities/TestQRFunctions.java @@ -1,13 +1,24 @@ -package utilities; - -import org.junit.Test; - -public class TestQRFunctions { - @Test - public void createQRCodeLocally() { - GenerateQRCode qrCode; - qrCode.createWebsiteQRCode(); - assertTrue(qrCode.validateQR = true); - } - -} +package utilities; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.junit.Test; + +import com.google.zxing.WriterException; + +import service.GenerateQRCode; + +public class TestQRFunctions { + @Test + public void createQRCodeLocally() { + GenerateQRCode qrCode = new GenerateQRCode(); + try { + qrCode.createWebsiteQRCode(); + } catch (WriterException | IOException e) { + e.printStackTrace(); + } + assertTrue(qrCode.validateQR); + } // End of createQRCodeLocally() +} // End of Class Declaration