Categories
Uncategorized

Set up Cucumber Guide

Needed for when someone wants to create automation via eclipse

Step-by-step guide

Selenium setup

  1. Download the Selenium Java Client Driver(http://docs.seleniumhq.org/download/)

    Download latest Java version. 

  2. Create a new folder with name say ‘Selenium’ in C drive and extract the jar files to ‘Selenium’ folder.

Jars to copy, copy the one in the default folder and then all the jars in the lib folder: (note versions might be different)

Cucumber setup:

  1. Download Cucumber jar files (https://mvnrepository.com/search?q=cucumber)

    Jars to download:

    Cucumber Core
    https://mvnrepository.com/artifact/info.cukes/cucumber-core
    Cucumber HTML
    https://mvnrepository.com/artifact/info.cukes/cucumber-html
    Cucumber JVM: Java

    https://mvnrepository.com/artifact/info.cukes/cucumber-java

    Cucumber JVM: Java8
    https://mvnrepository.com/artifact/info.cukes/cucumber-java8
    Cucumber JVM: JUnit
    https://mvnrepository.com/artifact/info.cukes/cucumber-junit
    Cucumber JVM: PicoContainer
    https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer
    Cucumber Report Generator
    https://mvnrepository.com/artifact/com.github.mkolisnyk/cucumber-report-generator
    Gherkin
    https://mvnrepository.com/artifact/info.cukes/gherkin
    Gherkin Repackaged Dependencies
    https://mvnrepository.com/artifact/info.cukes/gherkin-jvm-deps
  2. Create a new folder with name say Cucumber in C drive and extract the jar files to Cucumber folder.

Eclipse setup:

  1. In eclipse:

– Now Right-click on <project name> and select Properties.
– On the Properties window, click on “Java Build Path”.
– Click on the Libraries tab, and then click “Add External JARs..”
– Navigate to C:\selenium
– Add all the JAR files inside and outside the “libs” folder.

– Navigate to C:\cucumber
– Add all the JAR files inside
– Finally, click OK and we have completed importing Selenium and Cucumber libraries into our project.

Maven setup in Eclipse:

  1. File > New > ProjectSearch for Maven and select Maven Project

    Hit next, next, next

    Group Id: com.cucumber

    Artifact Id: MavenCucumber

    Package: com.cucumber.maven

    Update pom.xml file:

    project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
    xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd“>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cucumber</groupId>
    <artifactId>MavenBillFinRegressionSuite</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MavenBillFinRegressionSuite</name>
    <url>http://maven.apache.org</url>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.5</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>1.2.5</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.5</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>com.github.mkolisnyk</groupId>
    <artifactId>cucumber-reports</artifactId>
    <version>1.0.7</version>
    </dependency>
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>3.4.0</version>
    </dependency>
    </dependencies>
    </project>

Categories
Uncategorized

Pure JavaScript to format Date object to ISO String Date only

When working on Mongo Shell, I need to format currentDate to a ISODate  format String YYYY-MM-DD

var formatDate = function (date) {
day = date.getDate();
reportdate = date.getFullYear();
month = date.getMonth() + 1;

if (month < 10) {
reportdate = reportdate + “-0” + month;
} else {
reportdate = reportdate + “-” + month;
}

if (day < 10) {
reportdate = reportdate + “-0” + day;
} else {
reportdate = reportdate + “-” + day;
}
return reportdate;
}
var date = new ISODate(“2021-01-01T05:00:00.000Z”);

print(formatDate(date));

Categories
Uncategorized

/?a=fetch&content=die(@md5(HelloThinkCMF))

When I run a security scan on the log, I found the following:
[/?a=fetch&content=die(@md5(HelloThinkCMF))]

It looks like someone is trying to scan a PHP bug for wordpress site.

It is important to keep WordPress site up to date with the latest PHP version

Categories
BI Solution Uncategorized Web UI

Azure AD SSO Integration Error

When I trying to create a SAML Request for https://login.microsoftonline.com/xxxxx-xxxx-xxxx-xxxxx/saml2?SAMLRequest=[SAMLRequest redirect encode]

I have the following error message:

Request Id: xxxxxxxx-xxxx-446a-a8c8-84a3477d0600
Correlation Id: xxxxxxxx-xxxx-465d-83d9-6be5c98abec5
Timestamp: 2019-03-05T00:53:02Z
Message: AADSTS7500529: The value ‘817ef7d6-89a8-4367-8e41-39b1559305cd’ is not a valid SAML ID.

this GUID 817ef7d6-89a8-4367-8e41-39b1559305cd is generated with java.util.UUID tool. However, the Azure AD service is expecting an XML ID which has to meet the following requirement:

1.3.4 ID and ID Reference Values
The xs:ID simple type is used to declare SAML identifiers for assertions, requests, and responses. Values declared to be of type xs:ID in this specification MUST satisfy the following properties in addition to those
imposed by the definition of the xs:ID type itself:
• Any party that assigns an identifier MUST ensure that there is negligible probability that that party or any other party will accidentally assign the same identifier to a different data object.
• Where a data object declares that it has a particular identifier, there MUST be exactly one such declaration.
The mechanism by which a SAML system entity ensures that the identifier is unique is left to the implementation. In the case that a random or pseudorandom technique is employed, the probability of two
randomly chosen identifiers being identical MUST be less than or equal to 2-128 and SHOULD be less than or equal to 2-160
. This requirement MAY be met by encoding a randomly chosen value between 128 and 160 bits in length. The encoding must conform to the rules defining the xs:ID datatype. A pseudorandom
generator MUST be seeded with unique material in order to ensure the desired uniqueness properties
between different systems.

Page 9:  http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf

A simple solution is the add “id” in front of the string and remove any “-” from it.

it would similar to: id6c1c178c166d486687be4aaf5e482731

Categories
Uncategorized

GWT Callback parameter should be defined as final

It is convenient to just write java code and got converted into JavaScript. however there is a common compile error that will cause the compiler not able to compile the source code into java script. one of them is to provide a
*final* call back object with will be used inner class.

for example, in the following pseudo method:
public class JZCallBackService{

public void createObject(Foo dto, final CallbackObject callback) {

Ajax.Call(URL, new RestfulCallback() {
@Override
public void onSuccessful(Request request, Response response) {
callback.doSomthing();
}
});
}
}
if the CallbackObject is not defined as final, gwt compile will not be able to compile this class and an exception that JZCallBackService is not available to be used.

Categories
Uncategorized

How to add Phontomjs to JasperReport Studio 6.3 for Custom Visualisation Components

1. Download phantomjs from website
http://phantomjs.org/download.html

2. Extract to local disk:
C:\tool\phantomjs-2.1.1-windows

3. In windows:
Control Panel\System and Security\System

Advanced system settings->Advanced->Environment Variables

Update the path variable with
path = ..;C:\tool\phantomjs-2.1.1-windows\bin

4. Restart Jaspersoft Studio and start adding Custom Visulisation Components.

Here is the more detailed version from other author

http://community.jaspersoft.com/blog/step-step-procedure-run-existing-examples-d3-chart-samplesthat-comes-product-6x-jasper-design

 

Categories
Uncategorized

The Event Calendar-Ploylang

The Event Calendar is a very nice plugins for WordPress site, however, the Author is not considering the option of adding support for Ploylang plugins.

To fill this gap. I developed this plugins. you can upload the plugins to your WordPress site and activate it.

Download the the-event-calendar-ploylang

 

 

Categories
Uncategorized

How to Add custom domain name with amazon aws service and HTTPS/HTTP

After create an web app using aws, it is time to consider adding some security connection to the web app.

 

aws

Categories
Uncategorized

Knockoutjs Attr Binding tips

KnockoutJS is a MVVC framework which is very handy and light weight compared to AngularJS.  This post is to share a question I have face when work with the Attr Binding.

in IE8/9 if you want to use the Attribute Binding, it is better to put a Quote the attribute such that it would be able to avoid some keyword conflicting issue. ie: the ‘for’ attribute of a Label tag will cause knockoutjs failed to parse the tag.

<input type="radio" name="radio" id="radio1">
 <label data-bind="attr: {for:id}, text:label"></label>
<script type="text/javascript">
 var viewModel = function(){
      var self = this;
      self.id = ko.observable("radio1");
      self.label ="Yes - click me to check the button";
 };
ko.applyBindings(viewModel);
</script>

Try this out http://fiddle.jshell.net/452ctauL/2/

it will not work in IE8/IE9, but will work in Chrome/Firefox/iOS8+/IE11+

Categories
Uncategorized

Tips:Using Variables in JasperReport

When displaying the result from database, sometime we want to do something before we display the data. For example, you don’t want to display the question of pregnancy test result for a patient whom is male in the report.

There are many ways to do that. One way I have done is to create a Variables within the Dataset.  I can then refer to the same Variable in other Variables. One important aspect for Variable is that the order. You want to define the variable Prior to use it just as any programmer language.