|
1 | | -using System.IO; |
| 1 | +using System.Collections.Immutable; |
| 2 | +using System.IO; |
2 | 3 | using Bunq.Sdk.Model.Generated.Object; |
3 | 4 | using Newtonsoft.Json.Linq; |
4 | 5 |
|
5 | 6 | namespace Bunq.Sdk.Tests |
6 | 7 | { |
7 | 8 | public class Config |
8 | 9 | { |
| 10 | + /// <summary> |
| 11 | + /// Delimiter between the IP addresses in the PERMITTED_IPS field. |
| 12 | + /// </summary> |
| 13 | + private const char DELIMITER_IPS = ','; |
| 14 | + |
| 15 | + /// <summary> |
| 16 | + /// Length of an empty array. |
| 17 | + /// </summary> |
| 18 | + private const int LENGTH_NONE = 0; |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Field constants. |
| 22 | + /// </summary> |
9 | 23 | private const string FIELD_CONFIG_FILE_PATH = "../../../Resources/config.json"; |
10 | 24 | private const string FIELD_USER_ID = "USER_ID"; |
11 | 25 | private const string FIELD_API_KEY = "API_KEY"; |
12 | | - private const string FIELD_PERMITTED_IP = "ipAddress"; |
| 26 | + private const string FIELD_PERMITTED_IPS = "PERMITTED_IPS"; |
13 | 27 | private const string FIELD_ATTACHMENT_PUBLIC_TEST = "AttachmentPublicTest"; |
14 | 28 | private const string FIELD_ATTACHMENT_PATH_IN = "PATH_IN"; |
15 | 29 | private const string FIELD_ATTACHMENT_DESCRIPTION = "DESCRIPTION"; |
@@ -69,9 +83,13 @@ public static string GetAttachmentContentType() |
69 | 83 | return GetConfig()[FIELD_ATTACHMENT_PUBLIC_TEST][FIELD_ATTACHMENT_CONTENT_TYPE].ToString(); |
70 | 84 | } |
71 | 85 |
|
72 | | - public static string GetPermittedIp() |
| 86 | + public static string[] GetPermittedIps() |
73 | 87 | { |
74 | | - return GetConfig()[FIELD_PERMITTED_IP].ToString(); |
| 88 | + var permittedIpsString = GetConfig()[FIELD_PERMITTED_IPS].ToString(); |
| 89 | + |
| 90 | + return permittedIpsString.Length == LENGTH_NONE ? |
| 91 | + new string[LENGTH_NONE] : |
| 92 | + permittedIpsString.Split(DELIMITER_IPS); |
75 | 93 | } |
76 | 94 |
|
77 | 95 | public static string GetApiKey() |
|
0 commit comments