diff --git a/.travis.yml b/.travis.yml index 73018dc09..ff3e76108 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,18 +50,6 @@ jobs: notifications: email: false - - stage: 'Lint markdown files' - os: linux - language: generic - before_install: skip - install: - - npm i -g markdown-spellcheck - before_script: - - wget --quiet https://raw.githubusercontent.com/optimizely/mdspell-config/master/.spelling - script: - - mdspell -a -n -r --en-us '**/*.md' - after_success: skip - - stage: 'Integration tests' addons: srcclr: true diff --git a/core-httpclient-impl/README.md b/core-httpclient-impl/README.md index 0546a8f68..8e70b2ddb 100644 --- a/core-httpclient-impl/README.md +++ b/core-httpclient-impl/README.md @@ -171,6 +171,7 @@ The following builder methods can be used to custom configure the `HttpProjectCo |`withPollingInterval(Long, TimeUnit)`|5 minutes|Fixed delay between fetches for the datafile.| |`withBlockingTimeout(Long, TimeUnit)`|10 seconds|Maximum time to wait for initial bootstrapping.| |`withSdkKey(String)`|null|Optimizely project SDK key. Required unless source URL is overridden.| +|`withDatafileAccessToken(String)`|null|Token for authenticated datafile access.| ### Advanced configuration The following properties can be set to override the default configuration. @@ -182,6 +183,7 @@ The following properties can be set to override the default configuration. |**http.project.config.manager.blocking.duration**|10|Maximum time to wait for initial bootstrapping| |**http.project.config.manager.blocking.unit**|SECONDS|Time unit corresponding to blocking duration| |**http.project.config.manager.sdk.key**|null|Optimizely project SDK key| +|**http.project.config.manager.datafile.auth.token**|null|Token for authenticated datafile access| ## Update Config Notifications A notification signal will be triggered whenever a _new_ datafile is fetched. To subscribe to these notifications you can diff --git a/core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java b/core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java index 989e578f0..bd51a4cc0 100644 --- a/core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java +++ b/core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java @@ -1,6 +1,6 @@ /** * - * Copyright 2019, Optimizely + * Copyright 2019-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ *
  • {@link OptimizelyFactory#setBlockingTimeout}
  • *
  • {@link OptimizelyFactory#setPollingInterval}
  • *
  • {@link OptimizelyFactory#setSdkKey}
  • + *
  • {@link OptimizelyFactory#setDatafileAccessToken}
  • * * */ @@ -144,6 +145,19 @@ public static void setSdkKey(String sdkKey) { PropertyUtils.set(HttpProjectConfigManager.CONFIG_SDK_KEY, sdkKey); } + /** + * Convenience method for setting the Datafile Access Token on System properties. + * {@link HttpProjectConfigManager.Builder#withDatafileAccessToken(String)} + */ + public static void setDatafileAccessToken(String datafileAccessToken) { + if (datafileAccessToken == null) { + logger.warn("Datafile Access Token cannot be null. Reverting to default configuration."); + return; + } + + PropertyUtils.set(HttpProjectConfigManager.CONFIG_DATAFILE_AUTH_TOKEN, datafileAccessToken); + } + /** * Returns a new Optimizely instance based on preset configuration. * EventHandler - {@link AsyncEventHandler} diff --git a/core-httpclient-impl/src/test/java/com/optimizely/ab/OptimizelyFactoryTest.java b/core-httpclient-impl/src/test/java/com/optimizely/ab/OptimizelyFactoryTest.java index 8b595a019..c860ee98b 100644 --- a/core-httpclient-impl/src/test/java/com/optimizely/ab/OptimizelyFactoryTest.java +++ b/core-httpclient-impl/src/test/java/com/optimizely/ab/OptimizelyFactoryTest.java @@ -1,6 +1,6 @@ /** * - * Copyright 2019, Optimizely + * Copyright 2019-2020, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,6 +170,22 @@ public void setInvalidSdkKey() { assertEquals(expected, PropertyUtils.get(HttpProjectConfigManager.CONFIG_SDK_KEY)); } + @Test + public void setDatafileAccessToken() { + String expected = "datafile-access-token"; + OptimizelyFactory.setDatafileAccessToken(expected); + + assertEquals(expected, PropertyUtils.get(HttpProjectConfigManager.CONFIG_DATAFILE_AUTH_TOKEN)); + } + + @Test + public void setInvalidDatafileAccessToken() { + String expected = "datafile-access-token"; + OptimizelyFactory.setDatafileAccessToken(expected); + OptimizelyFactory.setDatafileAccessToken(null); + assertEquals(expected, PropertyUtils.get(HttpProjectConfigManager.CONFIG_DATAFILE_AUTH_TOKEN)); + } + @Test public void newDefaultInstanceInvalid() { optimizely = OptimizelyFactory.newDefaultInstance();