I use Web API that hard coded URL within Mobile Application (Develop With Xamarin).
I'll change this variable and rebuild When i need to swap between Test environment and Production environment.
Is there any best practice related to how to keep service URL?
Or how can I change environment without rebuild an application?
Thank you in advance.
You can add PRODUCTION and TEST as "Define Symbols" in Compiler tab for each target.
After than, You can use
string url = "";
#if PRODUCTION
url = "http://webpage.release
#endif
#if TEST
url = "http://webpage.test
#endif
Related
I am running the testcafe tests for a website. I want to avoid writing any browser cookies while running my testcafe tests. My website writes cookies but while running tests I want to avoid this. Is there any way to achieve this in testcafe?
To disable cookies in the Google Chrome browser, follow these steps:
Find the 'Preferences' file in the Google Chrome profile and specify 2 as the profile.default_content_settings.cookies key value.
Specify the :userProfile flag after the browser alias.
testcafe 'chrome:userProfile' /tests
If you want to have no cookies at the start of a test, note that TestCafe automatically clears cookies before each test is started.
You can use Role if you want to clear cookies at some point of your test scenario, for example, if you want to authenticate as a different user.
If your scenario is more complex, take a look at RequestMock and RequestHook - they allow you to control any aspect of all requests and responses during a test session.
I have a problem which seemed to be trivial at the beginning but now I am getting that it is very confusing.
So I am using reactjs for the front end of my application. I deploy my reactjs web app in a beanstalk in aws. In the beanstalk I define an environment variable called test and now I wanna read that and use it in my react application. But the problem is my react application is basically a client script in users browser so I cannot do something like this:
const config = {};
config.db = {
test: process.env.DB_DATABASE || 'my_db',
};
which is suggested in that link.
https://alexdisler.com/2016/03/26/nodejs-environment-variables-elastic-beanstalk-aws/
So I am doubting this is doable at all or it is something that is not possible.? any idea would be appreciated
Your react code will run in the browser, and will not be able to access the environment variables that have been set on the server.
The link you provided describes the process to set environment variables in a node.js environment that is hosted on an elastic beanstalk instance.
I suggest creating a config file in your react application that stores necessary parameters and initial settings you need to run your app.
I would like to get full URLs inside emails that get triggered by my tests in CakePHP 3.2. I tried with the full-options for $this->Html->image('image.jpg', ['fullBase' => true]) and $this->Url->build('/', true) but they don't seem to work in tests.
How can I force full URLs in emails while testing?
There is no host when running an app in the CLI environment as it's not a web request. You'll have to configure the base URL on your own.
Quote from the docs:
App.fullBaseUrl
The fully qualified domain name (including protocol)
to your application’s root. This is used when generating absolute
URLs. By default this value is generated using the $_SERVER
environment. However, you should define it manually to optimize
performance or if you are concerned about people manipulating the Host
header. In a CLI context (from shells) the fullBaseUrl cannot be read
from $_SERVER, as there is no webserver involved. You do need to
specify it yourself if you do need to generate URLs from a shell (e.g.
when sending emails).
So you can either configure it via App.fullBaseUrl
Configure::write('App.fullBaseUrl', 'http://localhost');
or a little more specific so that it only applies to the router, via Router::fullBaseUrl()
Router::fullBaseUrl('http://localhost');
You can either configure it in your application configuration (config/app.php), so that even on regular web requests your app isn't building it dynamically anmore, and consequently have it available in the test environment too, or, if you just want to apply to the test suite, put it either in your tests bootstrap (tests/bootstrap.php) to have it apply globally, or set it in your individual test case files.
That's what the CakePHP core test suite is doing it too btw. Whenever you're unsure, having a look at the core tests might give you a hint.
See also
Cookbook > Configuration > General Configuration
API > \Cake\Routing\Router::fullBaseUrl()
https://github.com/cakephp/cakephp/blob/3.2.13/tests/bootstrap.php#L70
https://github.com/cakephp/.../blob/3.2.13/tests/TestCase/Routing/RouterTest.php#L74
https://github.com/cakephp/.../3.2.13/tests/TestCase/Routing/RouterTest.php#L520-L529
I have a pretty standard express app, built using the express-generator. Now, I would like to automate some of the things in the app with hubot and I have managed to successfully perform testing and run hubot with slack adapter. However, I would like to have the bot be a part of a regular app.
How can I change the structure of the app (I have a pretty standard import of routes.js which has all of the routes for the app) to allow for the two to run together?
This is running on azure as a WebApp and I have set up a continuous integration with GitHub, so I pretty much just push code and it gets deployed, I don't run anything manually on the actual server. I would be able to run the hubot and server it on a different subdomain or path on the app if it was a regular VPS, but since the azure is taking care of those things, I would need the hubot somehow baked-in the actual express app.
As I know, Hubot has a build-in express web framework that can serve HTTP requests. So theoretically you can integrate hubot with your express webapp thru the router dispatch different urls between express app and hubot.
As references, there is a experimental package project hubot-express shows that hubot as a express app startup. you can try to refer to the code https://github.com/hubot-scripts/hubot-express/blob/master/src/hubot-express.coffee to implement the integration.
The key code: robot.express = app = express();
And the article "Automation and Monitoring with Hubot" show the code that how to serving http requests, please move to https://leanpub.com/automation-and-monitoring-with-hubot/read#leanpub-auto-serving-http-requests to review it.
The key code: robot.router.post('/hubot/notify/:room', function(req, res) {...});
To add to this, in the end I moved to botkit library that provides way easier and integrated way to have both the server and the actual app.
I am trying to create simple flex application, which uses django as a back-end part. Have a question:
Usually when I run my application Flex Builder creates a file in a directory on my local PC and then opens a browser and points to it. Everything was fine, but when I decided to link django server to flex applications via xml data providers I started to get security errors. (Related to absence of crossdomain.xml). When I created the file and put it on the server:
<?xml version="1.0"?>
<!-- http://www.foo.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="http://127.0.0.1:8000"/>
<allow-access-from domain="127.0.0.1"/>
</cross-domain-policy>
Then tried the application again, I got error in console of my FB Error: Request for resource at http://127.0.0.1:8000/go/active/ by requestor from file:///Users/oleg/Documents/FB3/usersList/bin-debug/usersList.swf is denied due to lack of policy file permissions.
I don't know how to fix the error. But also the question is there a way to configure FB3 to put my swf files to the server directly, so I will not need any crossdomain?
Thanks
Oleg
We struggled with this a lot. The Flex security stuff didn't strike me as well built, but perhaps we just had different approaches in mind than Adobe's developers. The solution that worked for us was to serve both the SWF and the dynamic data from the same host and port.
On our development boxes, we tell Apache to serve the SWF from a directory in the workspace, and the dynamic data from a local copy of the app. When we push to production, SWF and app get pushed simultaneously to the same virtual host.
If that's inconvenient for you, the Apache ProxyPass directive can be used to make Apache front for other servers. I've not used that in production, but it's been very handy for developer setups.
I don't know a way to get FlexBuilder to automatically deploy your changed SWF; you could certainly look into an automation approach (like Maven and Flex-Mojos) to make that happen.
That said, getting rid of that error is usually just a matter of adding a policy file to the server.
The second error is caused because you're trying to fetch http resources from a "file" location. My recommendation is that you change your Flex Builder project so it outputs to a location within the Django web site, rather than to the flex-bin directory. This setting can be changed in the properties dialog of the project. Then, you should be able to have your front-end and back-end share the same protocol and domain.