This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'aws-sdk' | |
@elb = Aws::ElasticLoadBalancing::Client.new(region: 'us-east-1') | |
@ec2 = Aws::EC2::Client.new(region: 'us-east-1') | |
def create_load_balancer | |
response = @elb.create_load_balancer( | |
load_balancer_name: "jboss-cluster-lb", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
try { | |
JAXBContext jaxbContext = JAXBContext.newInstance("com.prickettfamily.java.jaxb"); | |
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | |
Person person = (Person)unmarshaller.unmarshal(new File("/home/james/person.xml")); | |
assert person.getName().equals("John Doe"); | |
assert person.getPhone().equals("555-5555"); | |
assert person.getAddress().getStreet().equals("5 Somewhere Lane"); | |
} catch (JAXBException e) { | |
e.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def person = new XmlSlurper().parse("/home/james/person.xml") | |
assert person.name == "John Doe" | |
assert person.phone == "555-5555" | |
assert person.address[0].street == "5 Somewhere Lane" | |
assert person.address.find { [email protected]().contains("home") }.street == "5 Somewhere Lane" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<person> | |
<name>John Doe</name> | |
<phone>555-5555</phone> | |
<address type="home"> | |
<street>5 Somewhere Lane</street> | |
<city>Somewhere</city> | |
<state>MD</state> | |
<postalcode>12345</postalCode> | |
</address><address type="business"> | |
<street>12345 Business Street</street> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def "Verify View users do not have edit or admin menu options"() { | |
given: "A view user logs in" | |
login "viewuser", "password", DashboardPage | |
when: "The user should be landed on the dashboard" | |
waitFor { at DashboardPage } | |
then: "They should not have any edit or admin menu options" | |
assert $("li", id: "menu-users").size() == 0 | |
assert $("li", id: "menu-admin").size() == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def "Restrict users with the view permission"() { | |
when: "The user attempts to access an edit page" | |
login "viewuser", "password", MyReportsPage | |
then: "The user is shown an error message" | |
$().text().contains(AUTHORIZATION_ERROR_MSG) | |
when: "The user attempts to access an admin page" | |
to AdminPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from utils.security_utils import SecurityUtils | |
class TestUtils(unittest.TestCase): | |
def test_security_encode_user_id(self): | |
id = 154 | |
key = SecurityUtils.encode_user_id(id) | |
self.assertNotEquals(None, key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Cipher import AES | |
import base64 | |
import urllib | |
class SecurityUtils(object): | |
key = '^&#$SuP3rCR@zy$t%piDSEcu1+yK3Y$%&#' | |
mode = AES.MODE_CBC | |
pad_character = 'X' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
class HomePageTests extends BaseSpec { | |
def "Load the home page correctly"() { | |
when: | |
go "/" | |
then: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImdbServiceTests(unittest.TestCase): | |
def testGetIdsByPage(self): | |
service = ImdbService() | |
movie_ids = service.get_ids_from_page("http://www.imdb.com/chart/top") | |
self.assertNotEquals(None, movie_ids) | |
self.assertEquals(250, len(movie_ids)) | |
for id in movie_ids: | |
self.assertNotEquals(None, id) |
NewerOlder