Our mustard is made in small, hand-crafted batches.
We have been hand-crafting gourmet mustards in Sun Valley, Idaho for over 29 years. We use 100% quality ingredients and our mustards come in six delicious award winning flavors: Spicy-Sweet, Chardonnay, Amber Ale, Hot Jalapeno, Sweet Garlic and Dill.
We're a locally owned and operated company that uses the freshest and finest ingredients available to create flavors and textures totally different from anything currently available. Our mustards are made by hand in small batches to create our distinctive texture and flavor and NEVER with the use of artificial preservatives, flavors or colors.
Sun Valley Mustards have been featured on national television by QVC as one of the best food products in the country, and won more awards from the Idaho Specialty Foods Association than any other company in the State's history.


text:
Q: lonlat from geometry point gives strange result I added a vector layer to my main map with the controls like the example from openlayers: http://openlayers.org/dev/examples/draw-feature.html
Now when I want to get the resulting lonlat from the point that was drawn I get strange results:
({id:"OpenLayers.Geometry.Point_81", x:6418264.3901563, y:7161906.3780079,
      bounds:{left:6418264.3901563, bottom:7161906.3780079, right:6418264.3901563,
              top:7161906.3780079}})

The main map is constructed like this:
map = new OpenLayers.Map( $('map'), {
    sphericalMercator: true,
    //maxResolution: '360/512',
    maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
    projection: "EPSG:900913",
    displayProjection: new OpenLayers.Projection("EPSG:4326"),
    tileOrigin: new OpenLayers.LonLat(-180, -90),
    controls: [new OpenLayers.Control.Navigation({dragPanOptions: {enableKinetic: true}}),
                   new OpenLayers.Control.MousePosition(),new OpenLayers.Control.Zoom()],
eventListeners:{"moveend":mapEvent}
                                         });

Can somebody give me a hint, it's probably an easy thing but I'm quite new to openlayers and javascript in general :-)
Something with the conversion of projection ?

A: this is not a strange result, it gives you coordinate as map.projection which you have defined in map options  projection: "EPSG:900913"
try to use .transform method:
vectorLayers.features[1].geometry.transform(map.projection, map.displayProjection);

i hope it helps you...

redpajama_set_name: RedPajamaStackExchange


text:
Laura Dern is at the peak of her powers
Fuel Fix
Texas Inc.
TechBurger
Travel/Explore
ReNew Houston
Arts & Exhibits
Texas Flood Map
Bayou City Cookbook
Tracking COVID-19
Afternoon Report
Shop the Chronicle
Tim Greiving, The Washington Post
Laura Dern had two wildly different fillm roles this year: a cutthroat divorce lawyer in "Marriage Story" and a patient matriarch in "Little Women." MUST CREDIT: Photo for The Washington Post by Jessica Pons
Jessica Pons / For The Washington Post
LOS ANGELES — Laura Dern sashays in, dressed for success in form-fitting blue jeans, red heels and a cascade of perfectly situated blond hair. "Sorry I look so schleppy," she says. "I had an event at my kid's school."
Dern is Nora, the cutthroat divorce lawyer in Noah Baumbach's "Marriage Story," out on Netflix. Beautiful but spiky, heartless but hilarious, the role is the culmination of a career full of fierce feminists and rebels. Midway through the film, she stops texting for a moment to rail against the misguided, Judeo-Christian double standards that Western society holds against mothers.
But in the (metaphorical) theater next door this month, Dern is Marmee, the ever-patient, ever-loving matriarch in Greta Gerwig's adaptation of "Little Women." Buttoned up in the finery of a proud poor woman in 1860s New England, Marmee is the radiant, nurturing nucleus of a house spinning with four rambunctious girls, led by Saoirse Ronan's Jo.
"It's interesting to have these two women, two characters, who have, honestly, the greatest feminist writing ever - in two completely different worlds," Dern said recently over lunch in Santa Monica. "Between some of the lines I say to Saoirse - that are directly from the book, these lines that Louisa (May Alcott) wrote in the 1860s - about 'I'm angry nearly every day of my life,' and to talk about what it is to be an artist, and what it is to be a woman, and not to need to marry, and to love who you choose to love. I mean, it's some really radical thinking."
"And then, enter Century City divorce lawyer," she laughed, "and to have this monologue - that's absolutely accurate, you know, how mothers are measured differently than fathers - and with such sass, but also this sort of modern poetry of Noah's writing."
There was something "almost divine" about getting to play these two connected but wildly different roles in the same year, written by the two halves of a real-life couple.
"They really have a very similar rhythm in how they hear language," Dern said. "The words are so precise, but the mess they want to bring them forth, and the rhythm they need, is really amazing."
Baumbach and Gerwig are simply the latest filmmakers who are dying to work with Dern after watching her chart an adventurous and calibrated career over 40 years with directors such as David Lynch, Peter Bogdanovich, Robert Altman and Alexander Payne. Before her 25th birthday, she had played a pregnant teenager, a blind girl, a wide-eyed innocent and an outlaw's libidinous lover.
"What she was doing felt dangerous to me, in the best way," said Gerwig. "Because it felt like it was always at the very edge of what we can consider to be in good taste - which is the most wonderful acting and art of all. She was so committed to the truth of the thing that she completely stopped worrying about how she, Laura Dern, was coming across. It was just completely committed to the character, and committed to the extremities of the character."
Dern, 52, has been patiently planting a garden of great roles, coupling with auteur collaborators - but she has often been taken for granted.
"She's just now becoming a movie star," said her father, actor Bruce Dern, who noted both he and Laura's mother, Diane Ladd, toiled without stardom for years. "I'm somebody who has finally got to a place where I have opportunities to do things with my abilities. And Laura is finally getting that. She got it before, but in supporting kind of roles."
"Careers are long, and complicated," Laura Dern said. "There definitely were periods of time where I either wasn't working, or wasn't getting offered things that I wanted to do."
Her connection with film quite literally goes back to the beginning: She was conceived on the set of "The Wild Angels," a 1966 motorcycle movie in which her parents both starred. Their first daughter had drowned in a swimming pool a few years prior, and Bruce Dern keenly remembers a moment in 1974, when he was driving with 7-year-old Laura: "She turned to me and she said, 'Daddy, I miss my sister.' I pulled the car over, and I just had to say to myself, 'Where did that come from?' "
"That was the first time I noticed that there was caring beyond the level of the age she was," he said.
Dern grew up in the heart of Hollywood, rubbing shoulders with Alfred Hitchcock as a kid, and felt she was destined to act after Martin Scorsese complimented her ice-cream-eating endurance as an extra in "Alice Doesn't Live Here Anymore."
She grew up fast, finishing high school early and being legally emancipated from her parents when she was 16 so she could have grown-up working freedom. (Her first roommate was the family's "street minister" friend, Marianne Williamson.)
Bruce Dern gave his daughter two pieces of advice at the outset: "Learn how to dance" - i.e., don't let behind-the-scenes drama bother you - and "take risks." "You've got to go to the edge of the cliff," he told her, "and do roles other girls won't do."
When Dern was 18, Lynch cast her in his twisted suburban nightmare, "Blue Velvet," as the almost painfully innocent Sandy, who dreams of robins in a world gone to hell.
"I always thought she was wise beyond her years," said her co-star, Kyle MacLachlan. "She was just very intuitive and thoughtful and very aware. And she's never lost it."
Dern and MacLachlan, who dated for four years, reunited on camera more than 30 years later for Lynch's "Twin Peaks" revival on Showtime - which cast Dern as Sandy's polar opposite: the almost painfully acid-tonged Diane.
"She had talent from the very beginning," MacLachlan said. "But she also had a deeper drive, I think, to pursue work that was meaningful."
Dern upended whatever image we had of her in "Wild at Heart," writhing and dancing and screaming and crying - a heavy-metal Marilyn Monroe.
"She was working with Nicolas Cage, who is kind of the No. 1 fearless actor," said Lynch. "But Laura's got that in spades as well. She's pretty much fearless. She won't, I don't think, cut all her hair off. But I'm not positive about that."
Dern worked with another director hero, Steven Spielberg, in a part a few years later that would prove defining. Her "Jurassic Park" co-star, Sam Neill, noted her "wicked and subversive sense of humor."
"We would do our makeup stuff at the hotel, generally," Neill said by phone from New Zealand. "Jeff (Goldblum) would come back with his leg in a splint, blood all over him. And Laura and I would have a lot of fun pretending to kick him when he was down in the foyer of the hotel we were staying in, to the horror of Jeff and these tourists."
As Dr. Ellie Sattler in the 1993 blockbuster, Dern was fearless in a different way - rummaging through dinosaur droppings and casually taking down the scientific sexism of Neill and Goldblum's characters. She's noticed, in light of the #MeToo and Time's Up movements, various organizations using Sattler's quote from the 1993 film about "woman inherits the earth" as a rallying cry.
"She's been on T-shirts, and there have been dolls," Dern said. "I guess I hadn't clocked how much it meant to girls, at a time that they weren't seeing that regularly in giant action movies."
It's the main reason she agreed to reprise the role for "Jurassic World 3," which begins shooting next year.
It's maybe a curious choice, given how Dern has curated her career, taking risks to avoid being typecast - "and even typecast as an 'actress for hire,' " she said, "versus someone who wanted to learn and grow from great filmmakers."
"There was a lot I turned down, probably in my early 20s, as I was trying to establish the kind of career I would want now," she said. "My parents really - my dad particularly - talked to me a lot about that. So I was really making strategic choices, to build a body of work so that I would, when I was truly an adult woman with ownership of my life or maybe my creative choices, that I would get to play Nora and Marmee in the same year."
So where does a big-budget, ninth chapter of an adventure franchise fit into that equation?
"There's hesitation, in that you want it to feel right. You want them to honor all the characters. You want there to be a real valid reason they're all coming back - I think we can all imagine what that might be," she laughed.
"It's complicated," she admitted, "to figure out how to do it right. Because those movies can be so fun. I worked on a 'Star Wars' ("The Last Jedi") - I loved it. But I had a great director. Rian Johnson's a serious filmmaker. And the way he approached that movie was like any other independent film. He's all about character."
Her sights are set on several more auteurs she wants to work with, including Wes Anderson, the Coen Brothers and the "brothers from Mexico" - Alfonso Cuarón, Alejandro González Iñárritu and Guillermo del Toro. "And Scorsese is such an influence on my childhood and my choice to become an actress," she said, "so to work with him as an adult would be a very cool thing. Just as a ritual, almost."
When Dern watches her early performances now, she said, "I think I'm sort of patient like a mom. I feel proud of her for putting herself out there and being so young, and trying to be honest. I can also see the youth in certain things, but I'm not really critical."
"I don't know that I do that in my personal life," she confessed. "I think I beat myself up way more."
In some ways, modern Dern is equal parts Nora and Marmee: maternal, messy, dignified, ferocious. Gerwig finds it funny when people suggest that casting Dern as Marmee was counterintuitive.
"I knew that she would be loving, and she would be warm, and that she would be the mother we wish we had, and that also she would be able to be the person who says 'I'm angry almost every single day of my life' and we'd know that that was true," Gerwig said.
"And," the director added, "that she would be able to deliver to me the moment right before iconic Marmee starts. Who are you right before you walk in and say, 'Merry Christmas, my dears,' and they all crowd around you? Because there is a moment before, and I wanted the moment before, and I knew Laura could embody it."
Dern's onscreen daughter agrees.
"Marmee and Laura are very similar," said Ronan, who bonded with Dern over being film actors since childhood. "I feel like they're very sort of outspoken, but they also have like this talent for bringing people together."
What is the most un-Marmee thing about Laura Dern?
"Well," Ronan paused, "we were just talking about it a while ago, that like, a lot of rappers really admire Laura, apparently. I don't know if Marmee necessarily had that sort of admiration."
Partisan redistricting? Harris County maps show both parties...
Man fatally shot in north Houston
Police video shows exchange of gunfire between fatally shot man and...
Bellaire student says he was singled out over afro by coach
13 exciting new restaurants planned in Houston's suburbs
Tim Greiving
After 40 years, a murdered Houston couple has finally been ID'd. Where's their baby?
If the missing Houston baby is still alive, she would be turning 42 — although she likely doesn't know anything about her true identity.
By St. John Barned-Smith

redpajama_set_name: RedPajamaCommonCrawl


text:
GODIBLES
READING TODAY
READING TODAY Menu
Recent Speeches 02: The Truth of History Seen Through Heaven's Providence and Japan's Mission
by Godible December 11, 2019
Dr. Hak Ja Han Moon, affectionately known as True Mother, gave the main address at the Kanagawa Hyojeong Peace-Loving Festival held at the Makuhari Messe International Exhibition Hall in Kanagawa, Japan on October 15, 2017.
Distinguished guests from Japan and abroad, all members, globally, watching the broadcast to celebrate this day, and especially Family Federation blessed families from Kanagawa Prefecture, it is nice to see you all.
I heard that Kanagawa Prefecture has especially opened the gate to the beginning of a new Japan. Today, I would like to speak about this new era in "The Truth of History Seen through Heaven's Providence and Japan's Mission." When looking at all the phenomena occurring around the world today, it is hard to find hope. What this means is that people cannot bring an end to these problems. There is no solution to today's problems if we do not know the original Creator, God, the absolute God. God created all things in heaven and on earth and then created a man and a woman, who would become humankind's first ancestors. Unlike all other beings, God gave people responsibility over their period of growth. They should have matured with a heart of absolute faith, absolute love, and absolute obedience toward God, the Creator. However, Adam and Eve developed greed during that process. They began to look toward themselves. This led to today's fallen humankind. The Fall began from self-centeredness, so today the nations of the world, large and small, think first of their own benefit. The conclusion is that they cannot unite. Therefore, today I would like to explain our Creator's dream, our Heavenly Parent's dream.
God wished for Adam and Eve to complete the growth period and become the True Parents of humankind. However, because people did not fulfill their responsibilities, God had to wait. That was the providence of salvation and restoration through indemnity centered on people. In summary, a couple who can become the perfected True Parents must come from within humankind. Therefore, Heaven, through the Israelites, after the long period of four thousand years, sent Jesus Christ, whom God could call "My son!"
However, Jesus Christ could not be alone. A man cannot become a parent alone. When Jesus was crucified, he said, "I will return." Upon his return, he said he would hold the marriage supper of the Lamb. Thus, the essence of Christianity is to find the Only Begotten Daughter of God. However, Christianity began with the earnest wish of waiting for the return of Christ without understanding the essence of the providence. From the Italian Peninsula, Christianity spread across Europe and reached the island nation of Great Britain. The Atlantic Civilization Era was realized through Britain, and thus Christianity spread to the world.
In other words, Christians did not know Jesus' essence. They did not know what Heaven wished for. Christianity spread throughout the world, but eventually, nations began to think only of their own benefit. An economic revival began. Then, the focus of humankind's ultimate purpose shifted from knowing God and becoming happy in the eternal world to simply living and eating well. Looking at the ancient Egyptian civilizations or those on the Iberian Peninsula, people lived for and pursued self-happiness for future generations. I will say this again: if central figures or nations Heaven has chosen do not fulfill their responsibilities, Heaven will not use them again. Instead, Heaven will elevate a new nation, which can begin a new providence. That new nation is Korea, located on the Korean Peninsula.
I was born in 1943. Korea was liberated in 1945 and the Korean War began in 1950. One cause of that war was Japan. For geopolitical reasons, island nations often wish to encroach on peninsulas or continents. However, it is difficult for Heaven to bless this approach, because the nation acted out of self-centered greed, choosing to focus on benefiting their own nation.
Regardless, Heaven is alive and the providence progressed. After six thousand years, in Korea, Heaven found and elevated the Only Begotten Daughter of God and the Only Begotten Son of God and through them realized the ideal of True Parents. Conversely, the Korean War was a battle between democracy and communism. Believers in Democracy and in Communism, siblings, began to fight on the Korean Peninsula. Russia and China were already communist and supported North Korea. Democracy in South Korea was unprepared when the war began, but as if by a miracle, the United Nations entered the war to help defenseless South Korea.
This was Heaven's protection and blessing. Think about how much Heaven worked for this moment. Even in the midst of this situation, Japan revived economically following the Korean War. Heaven gave its blessing. If you receive Heaven's blessing, there is also responsibility that comes with it. True Parents blessed Japan as the Eve nation. Thus, the era of the Pacific Rim Civilization began centered on Korea, Japan, and the US. Unlike the past Atlantic Civilization Era, the Pacific Rim Civilization, centered on True Parents, is intended to unite humankind with a heart of filial piety toward Heaven. Japan was blessed as the mother nation, central in fulfilling that responsibility. A mother invests all her devotion to ensure her child's success and happiness. The mother's mission is to give unconditionally in order to fulfill God's and True Parents' dream and humankind's' wish in front of the 7.7 billion people in the world. When it is in this position, your nation can receive forgiveness for its past wrongdoings. Sensible people must recognize their wrongdoings. You must recognize them so you can start anew. I wish to say this to the politicians of this nation of Japan: You must know the truths of history.
I pray that this nation can be a mother nation to the world, free of tarnishes. The peace and happiness that you desire will increase the more you give. Just because you alone are happy does not mean that your happiness is eternal. For it to grow, you must share it.
In the preprogram, blessed families in our second-generation realm gave reports. They know True Parents and know True Parents' teachings. They have testified that they are not just second-generation members serving Japan, but global citizens who love and serve the world. If these second-generation members fill and then overflow this nation, and then go to the other 200+ nations around the world and fill them, without a doubt, the world's 7.7 billion people can realize the dream of one human family that attends God. I especially hope Kanagawa Prefecture, which has begun its' new history, can take-off and become the center of the world.
We are speaking of familial perfection. Japan is the mother nation. Korea is the father nation. The father and mother must lovingly unite in order for their children to be happy. Only then can you cleanse the troubling past. Then, a new era, a new history, will begin with the father nation, the mother nation, and representing the rest of the world, the eldest son nation, America. I pray these three nations at the center of the providence can realize the dream of a true human family under God and true world peace. Please know the dream of achieving this ideal is being realized throughout the world. On this point, I would like to say once again that Japan has an immense role in realizing world peace. I would like to conclude and pray that Heaven's eternal compassion be with the Kanagawa Prefecture and this nation of Japan.
Share this Godible. Start a conversation.
If you have any questions or concerns, please contact us at support@godible.org.
You can also share your testimony about Godible here!
Godible is brought to you by the National Victory Fund. To donate, click here.
Back to Daily Godible
© 2021, Godible.org Powered by Shopify
Copyright © 2019, FFWPU, USA. All Rights Reserved.


text:
The CLTD
Lexicon of Ontario Statutes and Regulations
Legal Glossary of Federal Statutes
Civil Procedure in Ontario
Estates forms: Wills
Formula templates
Model acts
Ontario case law: French translations
Access to case law in French from an individual's own jurisdiction is an essential key to the law for practitioners, law students, and an informed public; the Centre has therefore undertaken to make the decisions that it translates for the Ontario court system available on its own website, consisting of the decisions of the Court of Appeal for Ontario translated at the Centre since 1998. We provide access here to one of the few repositories of French-language decisions for Ontario.
Ontario case law in French was made possible until 2013 by the financial contribution of the Department of Justice Canada through the Access to Justice in Both Official Languages Support Fund, an initiative of the Roadmap for Canada's Official Languages 2013-2018: Education, Immigration, Communities. Since 2013, Ontario case law in French has been made possible by the joint financial contribution of the Law Society of Upper Canada and LexisNexis.
1588444 Ontario Ltd., faisant affaire sous la raison sociale d'Alfredo et autres v. State Farm Fire and Casualty Company
2251723 Ontario Inc. s/n VMedia v. Bell Canada et al.
243930 Alberta Ltd. v. Wickham (1990), 75 O.R. (2d) 289 (C.A.)
807933 Ontario Inc. v. Allison (1998), 38 O.R. (3d) 337 (C.A.)
861808 Ontario Inc. v. Canada (Revenue Agency)
Abbey et al. v. Essex County Board of Education(1999), 42 O.R. (3d) 490 (C.A.)
Abouchar v. Ottawa-Carleton (Conseil scolaire de langue française section publique) (2002), 58 O.R. (3d) 681 (C.S.)
Abrams v. Sprott Securities Ltd. (2003), 67 O.R. (3d) 368 (C.A.)
Adga Systems International Ltd. v. Valcom Ltd. (1999), 43 O.R. (3d) 101 (C.A.)
Adubofuor v. Director, Family Responsibility Office
Ajax c. National Automobile, Aerospace & Agricultural Implement Workers Union of Canada (CAW-Canada), Local 222 (1998), 41 O.R. (3d) 426 (C.A.)
Al-Diasty, R. v. (2003), 64 O.R. (3d) 618 (C.A.)
Alliance de la Fonction publique du Canada v. Procureur général du Canada (2002) 62 O.R./R.J.O. 695
Anderson, R. v. (2002), 57 O.R. (3d) 681 (C.A.)
Arland v. Taylor, (1955) O.R. 131, 3 D.L.R. 358 (C.A.)
Assaad v. The Economical Mutual Insurance Group et al.*
ASSOCIATION FOR REFORMED POLITICAL ACTION CANADA V. ONTARIO
Athans v. Canadian Adventure Camps Ltd. (1977), 17 O.R. (2d) 425 (C.S.)
B. (D.) v. Children's Aid Society of Durham [1996] 135 D.L.R. (4th) 297 (C.A.)
Ballentine v. Ballentine (1999), 45 O.R. (3d) 706 (C.S.)
Bangoura v. Washington Post, [2005] O.J. No. 3849
Bannister v. General Motors du Canada Ltd. (1998), 40 O.R. (3d) 591 (C.A.)
Bartlett v. Weiche Appartments Ltd. (1974), 7 O.R. (2d) 263 (C.A.)
Bata v. City Parking Canada Ltd. (1973), 43 D.L.R. (3d) 190, [1974] 2 O.R. (2d) 446
Beaird v. Westinghouse Canada Inc. (1999), 43 O.R. (3d) 581 (C.A.)
Beaudoin v. Brown et Eadie [1961] O.R. 429
Béchard v. Haliburton (succession) (1991), 5 O.R. (3d) 512 (C.A.)
Belende v. Patel et al.
Belvedere v. Brittain Estate
Berdette v. Berdette, [1991] 3 O.R. (3d) 513 (C.A.)
Bettel v. Yim (1978), 20 O.R (2d) 617 (C.c. Dist. York)
Bigcanoe v. Le Ministère du travail (Bureau des conseillers des travailleurs)
Bildy v. Bildy
Birce v. Birce
Bird v. Fort Frances (Ville de), (1949) O.R. 292 [1949] 2 D.L.R. 791 (H.C.J.)
Black et al. v. Owen et al.
Blackbird, R. v. (2003), 68 O.R. (3d) 763 (C.S.)
Blom, R. v. (2002), 61 O.R. (3d) 51 (C.A.)
Boardwalk Regency Corp. v. Maalouf (1992), 6 O.R. (3d) 737 à 758 (C.A.)
Bouchan v. Slipacoff
Bouzari v. Islamic Republic of Iran
Boyer v. Toronto Life Publishing Co. (2000), 48 O.R. (3d) 392 (C.S. )
Budd v. Paterson (2002), 62 O.R. (3d) 715 (C.A.)
Camarata v. Morgan
Caratun v. Caratum (1992) 42 R.F.L. (3ed) 113 C.A.
Cardinal v. Cleveland Indians Baseball Company Limited Partnership et al.
Carlingwood Motors Ltd. v. Nissan Canada Inc. (2001), 52 O.R. (3d) 242 (C.S.)
Carmichael v. Carmichael (Succession) (2000), 46 O.R. (3d) 630 (C.S.)
Catania v. Giannattasio (1999), 174 D.L.R. (4th) 170 (C.A.)
Catholic Children's Aid Society of Hamilton-Wentworth v. G. (J.), [1996] 90 O.A.C. 5 (C. just.)
Celanese Canada Inc. v. Murray Demolition Corp.
Chapman, R. v.
Charrette, R. v. (1998), 39 O.R. (3d) 407 (C.A.)
Chartrand, R. v. (2002), 62 O.R. (3d) 514 (C.A.)
Cheng v. Liu
Children's Aid Society of Peel v. W. (M.J.) (1995), 23 O.R. (3d) 174 (C.A.)
Citation : Enterprise Rent-a-Car Canada Limited v. Meloche Monnex Financial Services Inc., 2010 ONCA 277
CITATION: Canada Post Corporation v. Hamilton (City), 2016 ONCA 767
CITATION: Hamilton (City) v. Svedas Koyanagi Architects Inc., 2010 ONCA 887
City TV, R. v. (2000), 49 O.R. (3d) 756 (C.S.)
Collymore, R. v. (1999), 45 O.R. (3d) 713 (C.A.)
Contino v. Leonelli-Contino (2003), 67 O.R. (3d) 703 (C.A.)
Crits v. Sylvester, (1956) O.R. 132 (C.A.)
D'Onofrio et al. v. Advantage Car & Truck Rentals Limited et al.
Daly v. Ontario (Procureur-Général) (1999), 44 O.R 349 (C.A.)
David Electrical Contractor c.
Dawson, R. v. (1997), 39 O.R. (3d) 436 (C.A.)
Dehenne v. Dehenne (1999), 47 O.R. (3d) 140 (C.S.)
Dehenne v. Dehenne (1999), 47 O.R. (3d) 140 (C.S.) [version anglaise]
Del Grande v. Sebastian (1999), 27 E.T.R. (2d) 295 (C.S.)
Desbiens v. Mordini
Dimitrov, R. v. (2003), 68 O.R. (3d) 641 (C.A.)
Dodd v. Canada
Douglas, R. v. (2002), 62 O.R. (3d) 583 (C.A.)
Down, Re, 68 D.L.R. (2d) 30
Eady v. Waring (1974), 2 O.R. (2d) 627 (C.A.)
Edelstein Construction Ltd. v. The Fire Pit Inc. (1996), 30 O.R. (3d) 383 (C.A.)
Edwards v. Law Society of Upper Canada (2000), 48 O.R. (3d) 329 (C.A.)
Eglinton Place Inc. v. Ontario (2000), 47 O.R. (3d) 344 (C.S.)
Elmardy v. Toronto Police Services Board et al.
Essex County Roman Catholic Seperate School Board Re (1977), 17 O.R. (2d) 307 (H.C.J.)
États-Unis D'Amérique v. Sepehri (2004), 63 O.R. (3d) 691 (C.A.)
États-Unis D'Amérique v. The Shield Development Co. Ltd. et al., 74 O.R. (3d) 583
Feeley, R. v. (2001), 55 O.R. (3d) 481 (C.A.)
Fink, R. v. (2000), 51 O.R. (3d) 589 (C.A.)
Fisher, R. v. (2000), 47 O.R. (3d) 397 (C.A.)
Folino, R. v.
Francis v. Baker (1998), 38 O.R. (3d) 509 (C.A.)
Gaignard v. Canada (2003), 67 O.R. (3d) 611 (C.A.)
General Motors Acceptance Corp. of Canada, Ltd. v. Town and Country Chrysler Ltd. et al.
Gertsen v. Communauté urbaine de Toronto (1973), 2 O.R. (2d) 1 (C.S.)
Giorno v. Pappas (1999), 42 O.R. (3d) 626
GOLDEN OAKS ENTERPRISES INC. (TRUSTEE IN BANKRUPTCY OF) V. LALONDE
Gould (Succession v. Stoddart Publishing Co. (1998), 39 O.R. 555 (C.A)
Gregorio v. Intrans-Corp. (1994), 18 O.R. (3d) 527 (C.A.)
Grosman v. Cookson
Guarantee Company of North America et al. v. Mercedes-Benz
Guelph (ville) v. Wyndham Street Investments Inc. (2003), 63 O.R. (3d) 481 (C.A.)
Hall, R. v., (2000), 50 O.R. (3d) 257 (C.A.)
Halpern v. Toronto (Ville de) (2003), 65 O.R. (3d) 201 (C.A.)
Hanlan v. Sernesky (1998), 38 O.R. (3d) 479 (C.A.)
Hanlan v. Sernesky, [1996] 95 O.A.C. 297 (C.A.) Dossier No. C24999
Heeney v. Best (1979), 28 O.R. (2d) 71 (C.A..)
Heffron v. Imperial Parking Co. (1974), 3 O.R. (2d) 722 (C.A.)
Henderson, R. v. (1999), 44 O.R. (3d) 646 (C.A.)
Her Majesty the Queen v. B.S.
Her Majesty the Queen v. Brar
Her Majesty the Queen v. D.B.
Her Majesty the Queen v. Ohelo
Her Majesty the Queen v. Tinker et al. Her Majesty the Queen v. Eckstein Sa Majesté La Reine v. Larocque
Herrington, R. v. (2003), 68 O.R. (3d) 532 (C.A.)
Hill v. Hamilton-Wentworth Regional Police Services Board (2003), 66 O.R. (3d) 746 (C.S.)
Hodgkinson v. Economical Mutual Insurance Co. (2003), 68 O.R. (3d) 587 (C.A.)
Holmes et al. v. Board of Hospital Trustees of City of London et al. (1978), 17 O.R. (2d) 627 (H.C.J.)
Horne (Re) and Evans 60 O.R. (2d) 1 [1987] O.J. No. 495
Horner v. Horner
Hossein Ali Nakhostin-Ansari, R. c.
Hudson, R. c.
Huisman v. Huisman (1996), 30 O.R. (3d) 155 (C.A.)
Hunter, R. v.
Jabbaz v. Mouammar, [2003] O.J. No. 1616
Jacob et al., R. c.
Kauffman v. Toronto Transit Commission (1959), O.R. 197 (C.A.)
Kealey v. Berezowski (1996), 30 O.R. (3d) 37 (Ct. J.(Div. gén.))
Khazzaka v. Commercial Union Assurance Co. of Canada (2002), 66 O.R. (3d) 390 (C.A.)
Kilpatrick v. Hôpital civique de Peterborough (1999), 44 O.R. (3d) 321 (C.A.)
Kinsmen Club of Kingston v. Walker (2004) 69 O.R. (3d) 453 (C.S.)
Kirk v. McLaughlin Coal & Supplies Ltd. (1968), 1 O.R. 311 (C.A.)
Knoll v. Knoll, [1970] 2 O.R. 169 C.A.
Knox, R. v.
Koh, R. v. (1998), 42 O.R. (3d) 668 (C.A.)
Kovacs-Tatar, R. c.
Kozub v. Timko, Re. (1984), 45 O.R. (2d) 558
Kreutner v. Waterloo OxFord Co-operative Inc.
Kucor Construction & Developments & Associates v. Canada Life Assurance Co. (1998), 41 O.R. (3d) 577 (C.A.)
L. (A.G.) v. D. (K.B.)
LaFleur v. Canadian Bond Credits Ltd. (2003), 68 O.R. (3d) 754 (C. de petites créances)
Laing Estate v. Hines (1998), 41 O.R. (3d) 571 (C.A.)
Lalonde v. Ontario (Commission de restructuration des services de santé) (2001), 56 O.R. (3d) 577 (C.A.)
Lambert, Re (1994), 20 O.R. (3d) 108 (C.A.)
Landry v. Law Society of Upper Canada, Law Society Hearing Panel, 2011 ONSC 2947
Laredo Construction Inc. v. Baskaran Sinnadural
Laurin v. Iron Ore Co. of Canada, [1978] 82 D.L.R. (3d) 634 (C.S. (T.-N.))
Lavigne v. Attorney General of Ontario; Senate of Canada, Third Party
Lederer v. 372116 ONTARIO LIMITED (2001), 53 O.R. (3d) 203 (C.A.)
Leenen v. Canadian Broadcasting Corporation 54 O.R. (3d) 612 (C.A.)
Lessey, R. v.
Letford, R. v. (2001), 51 O.R. (3d) 737 (C.A.)
Lewis, R. v. (1998), 38 O.R. (3d) 540 (C.A.)
Litowitz v. Royal Trust Corp. of Canada
Livent Inc., Re (1999), 46 O.R. (3d) 463 (C.A.)
Lowe v. Lowe
M.(R.). v. M.(S.) (1994), 20 O.R. (3d) 621 (C.A.)
M.A.J. v. C.S., [2006] O.J. No. 4337
M.M. v. J.H.
Mack v. Canada (Procureur Général) (2002), 60 O.R. (3d) 756 (C.A.)
MacMillan v. McDermid (2003), 66 O.R. (3d) 632 (C.S.)
Macmillan v. Ontario (MINISTRY OF TRANSPORTATION AND COMMUNICATIONS), [2001] 24 M.V.R. (4th) 15 (C.A.)
Maddock v. Maddock, [1958] O.R. 810-833
Malette v. Shulman (1990), 72 O.R. (2d) 417 (C.A.)
Manitoba (Re the Queen in Right of) and Air Canada, 86 D.L.R. (3d) 631
Marshall et al. v. Bernard Place Corporation et al., 58 O.R. (3d) 97 [2002] O.J. No. 463
Masidon Investments Ltd. v. Ham, 45 O.R. (2d) 563
Matthews et al. v. MacLaren et al. 2 O.R. 137 (H.C.J.)
Mattick v. Ontario (Minister of Health) (2001), 52 O.R. (3d) 221 (C.A.)
McColgan Re (1969), 2 O.R. 152 (H.C.J.)
McCombie c. Cadotte (2001), 53 O.R. (3d) 704 (C.A.)
McIntyre (Succession) v. Scott (2003), 68 O.R (3d) 45 (C.A.)
McKenna v. Gammon Gold Inc.
McNamara v. Alexander Centre Industries Ltd. (2001), 53 O.R. (3d) 481 (C.A.)
McNeill, R. v. (2000), 48 O.R. (3d) 212 (C.A.)
Menear v. Miguna (1996), 30 O.R. (3d) 602 (C. Ont.(Div. gén.))
Miglin v. Miglin (2001), 53 O.R. (3d) 641 (C.A.)
Ministry of the Attorney General (Ontario) v. Black*
Minuskin, R. v. (2003), 68 O.R. (3d) 577 (C.A.)
Mohamed v. Département des services sociaux de la Communauté urbaine de Toronto (1996), 133 D.L.R. (4th) 108 (C.A.)
Myers v. Canadian Broadcasting Corp. (2001), 54 O.R. (3d) 633 (C.A.)
Napa Valley Private Winery Inc.(2003), 63 O.R. (3d) 636 (C.A.)
National Bank of Canada v. Clifford Chance (1996), 30 O.R. (3d) 746 (Ct. J.(Div. gén.))
National Steel Car Ltd., R. v. (2003), 63 O.R. (3d) 693 (C.A.)
Noble et al. V. Carnival Corporation 80 O.R. (3d) 392
Oakwell Engineering Ltd. v. Enernorth Industries Inc., 81 O.R. (3d) 288
Ohenhen, R. v.
Ontario College Of Pharmacists v. Katzman (2002), 223 D.L.R. (4th) 371 (C.A.)
Ordon (succession) v. Grail (1996), 30 O.R. (3d) 643 (C.A.)
Ostapchuk v. Ostapchuk (2003), 64 O.R. (3d) 496 (C.A.)
P. (J.), R. v. (2003), 64 O.R. (3d) 764 (C.S.)
Paithouski, Re, (1976), 13 O.R. (2e) 359 (H.C.), (1978), 18 O.R. (2e) 385 (C.A.)
Paragon Development Corporation v. Sonka Properties Inc., 2011 ONCA 30
PARKER PAD & PRINTING LTD. V. GORE MUTUAL INSURANCE CO.
Parsons (Succession) v. Guymer (1998), 40 O.R. (3d) 445 (C.A.)Patterson, R. c.
Patriarcki v. Attorney General of Canada
Patterson, R. v.
PDC 3 Ltd. Partnership v. Bregman & Hamann Architects (2001), 52 O.R. (3d) 533 (C.A.)
Pearson v. Adams (1914), 50 R.C.S. 204 (C.S.Can.)
Penner v. Regional Municipality of Niagara Police Services Board et al.
Perron (maintenant Waring) v. Perron
Perron v. Conseil scolaire de district catholique des Aurores boréales
Perron v. Perron, 2012 ONCA 811
Peter Paul, R. v. (2001), 52 O.R. (3d) 631 (C.A.)
Pliuskaitis v. Jotautas (1999), 47 O.R. (3d) 227 (C.S.))
Pollastro v. Pollastro (1999), 43 O.R. (3d) 497 (C.A.)
Pope v. Pope
R v Ohelo
R. v. R. (R.)
R. v. Swinkels, 2010 ONCA 742
R. v. V.(M.) (1998), 39 O.R. (3d) 217 (C.A.)
Rhys-Jones v. Rhys-Jones (2000), 48 O.R. (3d) 193 (C.A.)
Richardson (Succession) v. Mew
Riel v. Holland (2003), 67 O.R. (3d) 417 (C.A.)
Ross v. Hunter (1882), 7 R.C.S 289 (C.S.Can.)
Rowan c. Commission des valeurs mobilières de l'Ontario, 2010 ONSC 7029
Roy et al. v. North American Leisure Group Inc. et al.
Rozin v. Ilitchev (2003), 66 O.R (3d) 410 (C.A.)
RS. v. R.H. (2000), 52 O.R. (3d) 152
Rynard (Re) (1980), 31 O.R. (2d) 257
Sa Majesté la Reine v. Coulter
Sarrazin, R. c.
Scapillati v. A. Potvin Construction Ltd. (1999), 44 O.R. (3d) 737 (C.A.)
Seaway Gas & Fuel Ltd., R. v. (2000), 47 O.R. (3d) 468 (C.A.)
Sepe v. Monteleone
Shamas (Re) [1967] 2 O.R. 175 (C.A.)
Siddiqui v. Société Radio-Canada (2000), 50 O.R. (3d) 616 (C.A.)
Skyepharma plc v. Hyal Pharmaceutical Corporation
Skyway Canada Ltd. v. Clara Industrial Services Ltd. [2005] O.J. No. 4887
Smith v. MORRIS [1935] 2 D.L.R. 780
Southam (succession) v. MacTavish (2000), 52 O.R. (3d) 450 (C.S.)
Spence, R. v.
Spurgeon v. Spurgeon (2001), 53 O.R. (3d) 509 (C. Div.)
St. Clair Beach Estates Ltd. v. MacDonald (1974), 5 O.R. (2d) 482 (H.C.J.)
St. Lewis v. Rancourt; University of Ottawa, Non-party Participant
Stewart v. Nash (1988), 65 O.R. (2d) 218 (H.C.J.)
Stonehocker v. King (1998), 41 O.R (3d) 402 (C.A.)
Sutherland, R. v. (2000), 52 O.R. (3d) 27 (C.A.)
Swaby, R. v.
Szecket v. Huang (1998), 42 O.R. (3d) 400 (C.A.)
T. (J.C.) (1998), 39 O.R. (3d) 26 (C.A.), R. c.
T.B., R. c.
Taylor v. Taylor (2002), 60 O.R. (3d) 138 (C.A.)
Taylor v. The Attorney General of Canada
Teis v. Ancaster (Town of) (1997), 35 O.LR. (3d) 216
Tessling,R. v. (2003), 63 O.R. (3d) 1 (C.A.)
Thompson v. Mechan (1958), O.R. 357 (C.A.)
Toronto Star Newspapers Ltd. v. The Queen, 84 O.R. (3d) 766
Toronto Star Newspapers Ltd., R. v. (2003), 67 O.R. (3d) 577 (C.A.)
Toronto Taxi Alliance Inc. v. City of Toronto
Treesann Management Inc. v. Richmond Hill (2000), 47 O.R. (3d) 221 (C.A.)
Trewin v. Jones (1997), 32 O.R. (3d) 225 (C.A.)
Turcotte, R. v. (2000), 48 O.R. (3d) 97 (C.A.)
Turner v. DiDonato
United States v. Ivey (1996), 30 O.R. (3d) 370 (C.A.)
Urban Outdoor Trans Ad v. Scarborough (City) (2001), 52 O.R. (3d) 593 (C.A.)
Vallières v. Samson
Van de Vrande v. Butkowsky
Venn, R. v. (2000), 52 O.R. (3d) 37 (C.A.)
Walker (Re), [1925] O.J. No. 159, 56 O.L.R. 517
Walker & Taylor v. Boers (1996), 46 O.R. (3d) 372 (C.A.)
Waterloo (Municipalité régionale de) v. Jin-Di Yan
Webb v. 3584747 Canada Inc.
Willard v. Zurich Insurance Co.
Wong v. Lee (2002), 58 O.R. (3d) 398 (C.A.)
Wylie v. Leclair (2003), 64 O.R. (3d) 782 (C.A.)
Yepremian v. Scarborough General Hospital, 20 O.R. (2d) 510 (C.S.)
Yue v. Earl-McIntyre (2001), O.T.C. 85 (C.S.)
Zagdanski v. Zagdanski, (2001) 55 O.R. (3d) 6 (C.S.)
2020 © All right reserved: Centre for legal translation and documentation | Sitemap


text:
import json
import unittest
from urllib.parse import urlencode

from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.http import QueryDict
from django.test import TestCase
from rest_framework import status
from rest_framework.test import APIClient, APIRequestFactory

from powerdns.models import (
    DeleteRequest,
    Record,
    RecordRequest,
    RequestStates,
)
from powerdns.tests.utils import (
    DomainFactory,
    DomainTemplateFactory,
    RecordFactory,
    RecordRequestFactory,
    ServiceFactory,
    ServiceOwnerFactory,
    UserFactory,
)
from dnsaas.api.v2.views import RecordViewSet, IPRecordView
from dnsaas.api.v2.serializers import (
    RecordRequestSerializer, _trim_whitespace,
)

class TestApi(TestCase):
    def setUp(self):
        super().setUp()
        self.request_factory = APIRequestFactory()
        get_user_model().objects.create_superuser(
            'superuser', 'superuser@test.test', 'superuser'
        )
        get_user_model().objects.create_user(
            'user', 'user@test.test', 'user'
        )

        self.client = APIClient()
        self.client.login(username='user', password='user')

        domain = DomainFactory(
            name='example.com', type=None, unrestricted=False,
            auto_ptr=2,
            reverse_template=DomainTemplateFactory(name='reverse'),
        )
        for i in range(3):
            RecordFactory(
                type='A', name='example{}.com'.format(i),
                content='192.168.0.{}'.format(i),
                domain=domain,

            )
            RecordFactory(
                type='CNAME', name='www.example{}.com'.format(i),
                content='example{}.com'.format(i),
                domain=domain,
            )
            RecordFactory(
                type='TXT', name='example{}.com'.format(i),
                content='Some information{}'.format(i),
                domain=domain,
            )

    def test_record_filters_by_ip_and_type(self):
        request = self.request_factory.get('/')
        request.query_params = QueryDict(
            urlencode([
                ('ip', '192.168.0.1'),
                ('ip', '192.168.0.2'),
                ('type', 'A'),
                ('type', 'CNAME'),
                ('type', 'TXT'),
                ('type', 'PTR'),
            ])
        )

        mvs = RecordViewSet()
        mvs.request = request
        self.assertEqual(len(mvs.get_queryset()), 8)

class BaseApiTestCase(TestCase):
    def setUp(self):
        super().setUp()
        self.request_factory = APIRequestFactory()
        self.super_user = get_user_model().objects.create_superuser(
            'super_user', 'test@test.test', 'super_user'
        )
        self.client = APIClient()

    def send_post(self, url, data):
        return self.client.post(
            url, data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )

    def send_patch(self, url, data):
        return self.client.patch(
            # making requests by `format="json"` generates exception:
            # Unsupported media type "application/octet-stream" in request.
            url, json.dumps(data),
            content_type='application/json',
            **{
                'HTTP_ACCEPT': 'application/json; version=v2',
            }
        )

class TestRecords(BaseApiTestCase):
    def setUp(self):
        super().setUp()
        self.regular_user1 = get_user_model().objects.create_user(
            'regular_user1', 'regular_user1@test.test', 'regular_user1'
        )
        self.regular_user2 = get_user_model().objects.create_user(
            'regular_user2', 'regular_user2@test.test', 'regular_user2'
        )
        self.default_data = {
            'service': ServiceFactory().id,
        }

    def test_record_is_created_when_superuser(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'cname'.upper(),
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
            'service': ServiceFactory().id,
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

    def test_record_is_created_when_user_owns_domain(self):
        self.client.login(username='regular_user1', password='regular_user1')
        domain = DomainFactory(name='example.com', owner=self.regular_user1)
        self.default_data.update({
            'type': 'cname'.upper(),
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

    def test_record_is_not_created_when_domain_is_not_owned(self):
        self.client.login(username='regular_user1', password='regular_user1')
        domain = DomainFactory(name='example.com', owner=self.regular_user2)
        self.default_data.update({
            'type': 'cname'.upper(),
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)

    def test_validation_ip_address_if_domain_is_public(self):
        domain = DomainFactory(
            name='example2.com', owner=self.regular_user2,
            template=DomainTemplateFactory(
                is_public_domain=True, name="Public"
            )
        )
        self.client.login(username='regular_user1', password='regular_user1')

        self.default_data.update({
            'type': 'A',
            'domain': domain.id,
            'name': 'example2.com',
            'content': '10.0.0.0',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data['content'], ['IP address cannot be private.']
        )

    def test_user_is_set_correct_when_adding_record_with_owner(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'cname'.upper(),
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
            'owner': self.regular_user1.username,
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data['owner'], self.regular_user1.username)
        record_request = RecordRequest.objects.get(
            record__id=response.data['id'],
        )
        self.assertEqual(record_request.owner, self.super_user)
        self.assertEqual(record_request.target_owner, self.regular_user1)

    def test_user_is_set_correct_when_adding_record_without_owner(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'cname'.upper(),
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data['owner'], self.super_user.username)
        record_request = RecordRequest.objects.get(
            record__id=response.data['id'],
        )
        self.assertEqual(record_request.owner, self.super_user)
        self.assertEqual(record_request.target_owner, self.super_user)

    def test_record_creation_dumps_history_data_correctly(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'CNAME',
            'domain': domain.id,
            'name': 'example.com',
            'content': '192.168.0.1',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        record_request = RecordRequest.objects.get(
            record_id=response.data['id']
        )
        self.assertEqual(record_request.last_change_json, {
            'content': {'new': '192.168.0.1', 'old': ''},
            'name': {'new': 'example.com', 'old': ''},
            'owner': {'new': 'super_user', 'old': ''},
            'prio': {'new': '', 'old': ''},
            'remarks': {'new': '', 'old': ''},
            'ttl': {'new': 3600, 'old': ''},
            'type': {'new': 'CNAME', 'old': ''},
            '_request_type': 'create',
        })

    def test_rejected_record_creation_dumps_history_correctly(self):
        self.client.login(username='regular_user1', password='regular_user1')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'CNAME',
            'domain': domain.id,
            'name': 'www.example.com',
            'content': 'example.com',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        record_request = RecordRequest.objects.get(
            id=response.data['record_request_id']
        )

        self.assertFalse(record_request.last_change_json)
        record_request.reject()
        self.assertEqual(record_request.last_change_json, {
            'content': {'new': 'example.com', 'old': ''},
            'name': {'new': 'www.example.com', 'old': ''},
            'owner': {'new': 'regular_user1', 'old': ''},
            'prio': {'new': '', 'old': ''},
            'remarks': {'new': '', 'old': ''},
            'ttl': {'new': 3600, 'old': ''},
            'type': {'new': 'CNAME', 'old': ''},
            '_request_type': 'create',
        })

    def test_create_txt_record_removes_backslashes_from_content(self):
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.client.login(username='super_user', password='super_user')
        self.default_data.update({
            'type': 'TXT',
            'domain': domain.id,
            'name': 'www.example.com',
            'content': '\\a\\a\\',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.data['content'], 'aa')

    def test_post_raise_error_when_AAAA_content_is_invalid(self):
        self.client.login(username='regular_user1', password='regular_user1')
        domain = DomainFactory()
        data = {
            'type': 'AAAA',
            'domain': domain.id,
            'name': 'www.' + domain.name,
            'content': '192.168.0.1',
            'service': ServiceFactory().id,
        }
        response = self.send_post(reverse('api:v2:record-list'), data)

        self.assertEqual(response.status_code, 400)

    #
    # updates
    #
    def test_update_raise_error_when_record_has_no_owner_and_no_service(
        self
    ):
        self.client.login(username='regular_user1', password='regular_user1')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=None,
            service=None,
        )
        new_name = 'new-' + record.name

        assert record.service is None
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data,
            {'owner': ['Record requires owner to be editable. Please contact DNS support.']},  # noqa
        )

    def test_update_works_when_record_has_no_owner_but_has_service_owner(
        self
    ):
        self.client.login(username='regular_user1', password='regular_user1')
        so = ServiceOwnerFactory(owner=self.regular_user1)
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=None,
            domain__owner=self.regular_user1,
            service=so.service,
        )
        new_name = 'new-' + record.name

        assert record.service.owners.exists()
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )

        self.assertEqual(response.status_code, status.HTTP_200_OK)

    def test_update_record_when_recordrequest_doesnt_exist(self):
        self.client.login(username='super_user', password='super_user')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
        )
        new_name = 'new-' + record.name
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        record.refresh_from_db()
        self.assertEqual(record.name, new_name)
        self.assertEqual(
            RecordRequest.objects.filter(record__id=record.id).count(), 1
        )

    def test_update_record_when_cant_auto_accept(self):
        self.client.login(username='regular_user1', password='regular_user1')
        record_request = RecordRequestFactory(
            state=RequestStates.ACCEPTED.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        new_name = 'new-' + record_request.record.name
        response = self.client.patch(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
        record_request.record.refresh_from_db()
        self.assertFalse('new' in record_request.record.name)
        self.assertEqual(
            RecordRequest.objects.filter(
                record__id=record_request.record.id
            ).count(),
            2,
        )

    def test_reject_update_when_request_already_exists(self):
        self.client.login(username='regular_user1', password='regular_user1')
        record_request = RecordRequestFactory(
            state=RequestStates.OPEN.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        new_name = 'new-' + record_request.record.name
        response = self.client.patch(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(
            response.status_code, status.HTTP_412_PRECONDITION_FAILED,
        )
        self.assertEqual(
            response.data['record_request_ids'][0], record_request.id
        )

    def test_allow_update_when_request_already_exists_but_superuser(
        self
    ):
        self.client.login(username='super_user', password='super_user')
        record_request = RecordRequestFactory(
            state=RequestStates.OPEN.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        new_name = 'new-' + record_request.record.name
        response = self.client.patch(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        record_request.record.refresh_from_db()
        self.assertEqual(record_request.record.name, new_name)
        self.assertEqual(
            RecordRequest.objects.filter(
                record__id=record_request.record.id
            ).count(),
            2,
        )

    def test_user_is_set_correct_when_updating_record_with_owner(self):
        self.client.login(username='super_user', password='super_user')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=self.regular_user1,
        )
        new_name = 'new-' + record.name
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={
                'name': new_name,
                'owner': self.regular_user2.username,
            },
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        record.refresh_from_db()
        self.assertEqual(record.owner, self.regular_user2)
        record_request = RecordRequest.objects.get(record__id=record.id)
        self.assertEqual(record_request.owner, self.super_user)
        self.assertEqual(record_request.target_owner, self.regular_user2)

    def test_user_is_set_correct_when_updating_record_without_owner(self):
        self.client.login(username='super_user', password='super_user')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=self.regular_user1,
        )
        new_name = 'new-' + record.name
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'name': new_name},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        record.refresh_from_db()
        self.assertEqual(record.owner, self.regular_user1)
        record_request = RecordRequest.objects.get(record__id=record.id)
        self.assertEqual(record_request.owner, self.super_user)
        self.assertEqual(record_request.target_owner, None)

    def test_owner_keeps_value_when_no_owner_in_update(self):
        """
        1. Create record r1 with owner o1
        2. Create record request (rr1) for r1 without owner
        3. r1 gets update on owner to o2 while acceptation is pending
        4. rr1 gets acceptation
        5. r1.owner == o2
        """
        self.client.login(username='regular_user1', password='regular_user1')
        record = RecordFactory(
            type='A',
            name='blog.com',
            remarks='initial remarks',
            content='192.168.1.0',
            owner=self.super_user,
        )
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'remarks': 'updated remarks'},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
        record.owner = self.regular_user2
        record.save()
        RecordRequest.objects.get(record=record).accept()
        record.refresh_from_db()
        self.assertEqual(record.owner, self.regular_user2)
        self.assertEqual(record.remarks, 'updated remarks')

    def test_record_update_dumps_history_data_correctly(self):
        self.client.login(username='super_user', password='super_user')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=self.regular_user1,
        )
        new_name = 'new-' + record.name
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={
                'name': new_name
            },
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        record_request = RecordRequest.objects.get(
            record_id=response.data['id']
        )
        self.assertEqual(record_request.last_change_json['name'], {
            'old': record.name,
            'new': new_name,
        })
        self.assertEqual(record_request.last_change_json['remarks'], {
            'old': record.remarks,
            'new': record.remarks,
        })

    def test_rejected_record_update_dumps_history_correctly(self):
        self.client.login(username='regular_user1', password='regular_user1')
        self.default_data.update({
            'domain': DomainFactory(name='example.com', owner=self.super_user),
            'type': 'CNAME',
            'name': 'www.example.com',
            'content': 'example.com',
            'remarks': 'initial',
            'owner': self.regular_user1,
            'service': ServiceFactory(),
        })
        to_update = RecordFactory(**self.default_data)
        response = self.client.patch(
            reverse('api:v2:record-detail', kwargs={'pk': to_update.pk}),
            data={'remarks': 'update'},
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        record_request = RecordRequest.objects.get(
            id=response.data['record_request_id']
        )

        self.assertFalse(record_request.last_change_json)
        record_request.reject()
        self.assertEqual(record_request.last_change_json, {
            'content': {'new': '', 'old': self.default_data['content']},
            'name': {'new': '', 'old': self.default_data['name']},
            'owner': {'new': '', 'old': self.default_data['owner'].username},
            'prio': {'new': '', 'old': ''},
            'remarks': {'new': 'update', 'old': self.default_data['remarks']},
            # old=3600 its because it's model default
            # when update request is send, new RecordRequest is created
            # if user doesn't specify ttl (or other value which has default)
            # it is set on model and diff uses models value which are already
            # set, so it can't be distinguish if eg. 3600 was from default of
            # from user
            'ttl': {'new': 3600, 'old': 3600},
            'type': {'new': '', 'old': self.default_data['type']},
            '_request_type': 'update',
        })

    def test_patch_raise_error_when_AAAA_content_is_invalid(self):
        self.client.login(username='regular_user1', password='regular_user1')
        record = RecordFactory(owner=self.regular_user1)

        response = self.send_patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={
                'type': 'AAAA', 'content': '192.168.1.1'
            },
        )

        self.assertEqual(response.status_code, 400)

    #
    # deletion
    #
    def test_superuser_deletes_records_with_opened_request(self):
        """Superuser can delete record with OPENED record-requests"""
        self.client.login(username='super_user', password='super_user')
        record_request = RecordRequestFactory(
            state=RequestStates.OPEN.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        response = self.client.delete(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        # record_request.refresh_from_db doesn't refresh since
        # record_request.record is on_delete=models.DO_NOTHING, so get record
        # by query
        self.assertEqual(
            RecordRequest.objects.get(pk=record_request.id).record_id,
            record_request.record_id,
        )
        with self.assertRaises(Record.DoesNotExist):
            RecordRequest.objects.get(pk=record_request.id).record
        self.assertTrue(
            DeleteRequest.objects.get(target_id=record_request.record_id)
        )

    def test_delete_raise_error_when_record_misses_owner_and_service_owner(
        self
    ):
        self.client.login(username='regular_user1', password='regular_user1')
        record = RecordFactory(
            type='A',
            name='blog.com',
            content='192.168.1.0',
            owner=None,
            service=None,
        )
        response = self.client.delete(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record.pk},
            ),
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data,
            {'owner': ['Record requires owner to be deletable. Please contact DNS support.']},  # noqa
        )

    def test_user_cant_delete_record(self):
        """Regular user can't delete record"""
        self.client.login(username='regular_user1', password='regular_user1')
        record_request = RecordRequestFactory(
            state=RequestStates.ACCEPTED.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        response = self.client.delete(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
        self.assertTrue(Record.objects.get(id=record_request.record.id))
        self.assertEqual(
            DeleteRequest.objects.filter(
                target_id=record_request.record.id
            ).count(),
            1,
        )

    def test_user_cant_delete_record_with_opened_request(self):
        """Regular user can't delete record when OPENED record-request
        exists"""
        self.client.login(username='regular_user1', password='regular_user1')
        record_request = RecordRequestFactory(
            state=RequestStates.OPEN.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        response = self.client.delete(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(
            response.status_code, status.HTTP_412_PRECONDITION_FAILED,
        )
        self.assertTrue(Record.objects.get(id=record_request.record.id))
        self.assertEqual(
            DeleteRequest.objects.filter(
                target_id=record_request.record.id
            ).count(),
            0,
        )

    def test_record_deletion_dumps_history_data_correctly(self):
        self.client.login(username='super_user', password='super_user')
        record_request = RecordRequestFactory(
            state=RequestStates.OPEN.id,
            record__type='A',
            record__name='blog.com',
            record__content='192.168.1.0',
        )
        response = self.client.delete(
            reverse(
                'api:v2:record-detail',
                kwargs={'pk': record_request.record.pk},
            ),
            format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        delete_request = DeleteRequest.objects.get(
            target_id=record_request.record_id
        )
        self.assertEqual(delete_request.last_change_json, {
            'content': {'new': '', 'old': '192.168.1.0'},
            'name': {'new': '', 'old': 'blog.com'},
            'owner': {'new': '', 'old': record_request.record.owner.username},
            'prio': {'new': '', 'old': ''},
            'remarks': {'new': '', 'old': ''},
            'ttl': {'new': '', 'old': 3600},
            'type': {'new': '', 'old': 'A'},
            '_request_type': 'delete',
        })

    @unittest.skip("todo when DeleteRequest and ChangeRequest are unified")
    def test_rejected_record_deletion_dumps_history_correctly(self):
        pass

class TestRecordValidation(BaseApiTestCase):
    def setUp(self):
        super().setUp()
        self.default_data = {
            'service': ServiceFactory().id,
        }

    def test_validation_error_when_A_record_name_is_bad(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'A',
            'domain': domain.id,
            'name': 'this-is-bad-bad-value-for-name',
            'content': 'this-is-bad-bad-value-for-content',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertTrue(response.data['name'])

    def test_validation_error_when_A_record_content_is_bad(self):
        self.client.login(username='super_user', password='super_user')
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.default_data.update({
            'type': 'A',
            'domain': domain.id,
            'name': 'www.' + domain.name,
            'content': 'ThisIsBadBadValueForContent',
        })
        response = self.client.post(
            reverse('api:v2:record-list'), self.default_data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertTrue(response.data['content'])

class TestObtainAuthToken(TestCase):

    def setUp(self):  # noqa
        self.client = APIClient()  # do not login
        self.user = UserFactory()

    def test_should_return_token_when_correct_credentials_were_sent(self):
        response = self.client.post(
            reverse('get-api-token'),
            {'username': self.user.username, 'password': 'password'},
            format='json',
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            response.data['token'],
            str(self.user.auth_token),
        )

    def test_should_return_400_when_incorrect_credentials_were_sent(self):
        response = self.client.post(
            reverse('get-api-token'),
            {'username': self.user.username, 'password': 'bad-password'},
            format='json',
        )
        self.assertEqual(response.status_code, 400)

class TestRecordRequestSerializer(TestCase):

    def setUp(self):  # noqa
        self.client = APIClient()  # do not login
        self.user = UserFactory()

    def test_last_change_comes_from_dump_when_status_not_open(self):
        rr = RecordRequestFactory(
            state=RequestStates.OPEN, target_remarks='initial',
        )
        rr.accept()
        serializer = RecordRequestSerializer(rr)

        self.assertEqual(serializer.instance.record.remarks, 'initial')
        self.assertEqual(
            serializer.data['last_change']['remarks']['new'],
            'initial',
        )

        rr.record.remarks = 'updated'
        rr.record.save()
        rr.refresh_from_db()

        serializer = RecordRequestSerializer(rr)
        self.assertEqual(serializer.instance.record.remarks, 'updated')
        self.assertEqual(
            serializer.data['last_change']['remarks']['new'],
            'initial',
        )

    def test_last_change_is_calculated_when_status_open(self):
        rr = RecordRequestFactory(
            state=RequestStates.OPEN, target_remarks='update 1',
            record__remarks='initial'
        )
        serializer = RecordRequestSerializer(rr)

        self.assertEqual(
            serializer.data['last_change']['remarks']['old'],
            rr.get_object().remarks,
        )
        self.assertEqual(
            serializer.data['last_change']['remarks']['new'],
            serializer.instance.target_remarks
        )

        rr.record.remarks = 'update 2'
        rr.record.save()
        rr.refresh_from_db()

        serializer = RecordRequestSerializer(rr)
        self.assertEqual(
            serializer.data['last_change']['remarks']['old'],
            rr.get_object().remarks,
        )
        self.assertEqual(
            serializer.data['last_change']['remarks']['new'],
            serializer.instance.target_remarks
        )

class TestDomainSelecting(BaseApiTestCase):
    def setUp(self):
        super().setUp()
        self.data = {
            'type': 'CNAME',
            'name': 'www.example.com',
            'content': 'example.com',
            'service': ServiceFactory().id,
        }
        self.client.login(username='super_user', password='super_user')

    def test_domain_is_used_when_is_send_in_request(self):
        domain = DomainFactory(name='example.com', owner=self.super_user)
        self.data['domain'] = domain.id

        response = self.client.post(
            reverse('api:v2:record-list'), self.data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )

        self.assertEqual(
            Record.objects.get(pk=response.data['id']).domain.id,
            domain.id,
        )

    def test_domain_is_taken_from_record_when_is_absent_in_request(self):
        domain = DomainFactory(name='example.com', owner=self.super_user)
        response = self.client.post(
            reverse('api:v2:record-list'), self.data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(
            Record.objects.get(pk=response.data['id']).domain.id,
            domain.id,
        )

    def test_raise_error_when_domain_cant_be_found(self):
        self.data['name'] = 'unknown-domain.com'
        response = self.client.post(
            reverse('api:v2:record-list'), self.data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )
        self.assertEqual(
            response.data,
            {'domain': ['No domain found for name unknown-domain.com']}
        )

class TestTrimmingSpaces(TestCase):

    def test_trim_works_ok(self):
        data = {'field': ' a '}
        _trim_whitespace(data, ('field', ))
        self.assertEqual(data['field'], 'a')

    def test_skips_not_specified_field(self):
        data = {'field': ' a '}
        _trim_whitespace(data, ('some-other-field', ))
        self.assertEqual(data['field'], ' a ')

class TestIPRecordTest(BaseApiTestCase):
    def setUp(self):
        super().setUp()
        self.client.login(username='super_user', password='super_user')
        self.domain = DomainFactory(name='example.com', owner=self.super_user)
        self.domain_2 = DomainFactory(name='google.com', owner=self.super_user)
        self.data = {
            'new': {},
            'old': {},
            'action': 'add'
        }

    def _send_post_data_to_endpoint(self):
        return self.client.post(
            reverse('api:v2:ip-record'), self.data, format='json',
            **{'HTTP_ACCEPT': 'application/json; version=v2'}
        )

    def test_validate_add_data(self):
        self.data = {
            'action': 'add',
            'old': {
                'address': '127.0.0.1',
                'hostname': 'localhost'
            },
            'new': {
                'address': '127.0.0.1',
                'hostname': 'localhost'
            }
        }
        self.assertTrue(IPRecordView._validate_data(self.data))

    def test_validate_incorrect_add_data(self):
        self.data = {
            'action': 'add',
            'old': {
                'address': '127.0.0.2',
                'hostname': 'localhost'
            },
            'new': {
                'address': '127.0.0.1',
                'hostname': 'localhost'
            }
        }
        self.assertFalse(IPRecordView._validate_data(self.data))

    def test_validate_incorrect_add_data_without_hostname(self):
        self.data = {
            'action': 'add',
            'old': {
                'address': '127.0.0.1',
                'hostname': None
            },
            'new': {
                'address': '127.0.0.1',
                'hostname': None
            }
        }
        self.assertFalse(IPRecordView._validate_data(self.data))

    def test_add_record(self):
        self.data.update({
            'old': {
                'address': '127.0.0.1',
                'hostname': 'test123.example.com'
            },
            'new': {
                'address': '127.0.0.1',
                'hostname': 'test123.example.com'
            }
        })
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)

    def test_create_duplicate_record(self):
        self.data.update({
            'old': {
                'address': '127.0.0.1',
                'hostname': 'test123.example.com'
            },
            'new': {
                'address': '127.0.0.1',
                'hostname': 'test123.example.com'
            }
        })
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 409)

    def test_update_record(self):
        target_content = '192.168.1.8'
        target_name = 'test_update_2.{}'.format(self.domain.name)
        record = RecordFactory(
            type='A',
            content='127.0.0.9',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        self.data.update({
            'old': {
                'address': record.content,
                'hostname': record.name
            },
            'new': {
                'address': target_content,
                'hostname': target_name
            },
            'action': 'update',
        })
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)
        record.refresh_from_db()
        self.assertEqual(record.content, target_content)
        self.assertEqual(record.name, target_name)

    def test_update_txt_records_when_record_name_change(self):
        target_name = 'new-value.{}'.format(self.domain.name)
        record = RecordFactory(
            type='A',
            content='127.0.0.9',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        record_txt = RecordFactory(
            type='TXT',
            content='Rack 1',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        self.data.update({
            'old': {
                'address': record.content,
                'hostname': record.name
            },
            'new': {
                'address': record.content,
                'hostname': target_name
            },
            'action': 'update',
        })
        self.assertNotEqual(self.data['new'], self.data['old'])

        response = self._send_post_data_to_endpoint()

        self.assertEqual(response.status_code, 200)
        record.refresh_from_db()
        record_txt.refresh_from_db()
        self.assertEqual(record.name, target_name)
        self.assertEqual(record_txt.name, target_name)

    def test_update_txt_records_when_record_name_and_domain_change(self):
        target_name = 'update_test_1.{}'.format(self.domain_2.name)
        record = RecordFactory(
            type='A',
            content='127.0.0.9',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        record_txt = RecordFactory(
            type='TXT',
            content='Rack 2',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        self.data.update({
            'old': {
                'address': record.content,
                'hostname': record.name
            },
            'new': {
                'address': record.content,
                'hostname': target_name
            },
            'action': 'update',
        })
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)
        record.refresh_from_db()
        record_txt.refresh_from_db()
        self.assertEqual(record.name, target_name)
        self.assertEqual(record.domain_id, self.domain_2.id)
        self.assertEqual(record_txt.name, target_name)

    def test_delete_txt_records_when_record_delete(self):
        record = RecordFactory(
            type='A',
            content='127.0.0.9',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        record_txt = RecordFactory(
            type='TXT',
            content='Rack 1',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        self.data = {
            'address': record.content,
            'hostname': record.name,
            'action': 'delete'
        }
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)
        self.assertFalse(Record.objects.filter(id=record.id).exists())
        self.assertFalse(Record.objects.filter(id=record_txt.id).exists())

    def test_when_hostname_is_empty_in_new_then_delete_record(self):
        record = RecordFactory(
            type='A',
            content='127.0.0.9',
            name='update_test_1.{}'.format(self.domain.name),
            domain=self.domain
        )
        self.data.update({
            'old': {
                'address': record.content,
                'hostname': record.name
            },
            'new': {
                'address': record.content,
                'hostname': None
            },
            'action': 'update',
        })
        response = self._send_post_data_to_endpoint()
        self.assertEqual(response.status_code, 200)
        self.assertFalse(Record.objects.filter(id=record.id).exists())

    def test_delete_record(self):
        target_content = '192.168.1.8'
        target_name = 'test_update_2.{}'.format(self.domain.name)
        record_kwargs = {
            'type': 'A',
            'content': target_content,
            'name': target_name,
            'domain': self.domain
        }
        RecordFactory(**record_kwargs)
        self.data = {
            'address': target_content,
            'hostname': target_name,
            'action': 'delete'
        }
        self._send_post_data_to_endpoint()
        self.assertFalse(Record.objects.filter(**record_kwargs).exists())

    def test_delete_nonexistent_record(self):
        self.data = {
            'address': '192.168.1.0',
            'hostname': '404.dc',
            'action': 'delete'
        }
        self._send_post_data_to_endpoint()

class TestServiceField(BaseApiTestCase):
    def setUp(self):
        self.guest = get_user_model().objects.create_user(
            'guest', 'guest@example.com', 'guest'
        )
        self.owner_with_access = get_user_model().objects.create_user(
            'owner_with_access', 'owner_with_access@example.com',
            'owner_with_access'
        )
        self.domain = DomainFactory(
            name='example.com', owner=self.owner_with_access
        )

    def _record_for_update(self):
        return RecordFactory(
            domain=self.domain,
            owner=self.owner_with_access,
            type='A',
            name='www.' + self.domain.name,
            content='192.168.1.1',
            service=None,
        )

    def test_create_record_saves_service(self):
        self.client.login(
            username='owner_with_access', password='owner_with_access'
        )
        service = ServiceFactory()

        response = self.send_post(
            reverse('api:v2:record-list'),
            {
                'type': 'A',
                'domain': self.domain.id,
                'name': 'example.com',
                'content': '192.168.0.1',
                'service': service.id,

            },
        )

        record = Record.objects.get(pk=response.data['id'])
        self.assertEqual(record.service.id, service.id)
        self.assertEqual(response.data['service'], service.id)

    def test_create_record_raise_error_when_no_service(self):
        self.client.login(
            username='owner_with_access', password='owner_with_access'
        )

        response = self.send_post(
            reverse('api:v2:record-list'),
            {
                'type': 'A',
                'domain': self.domain.id,
                'name': 'example.com',
                'content': '192.168.0.1',
            },
        )

        self.assertEqual(
            response.data['service'], ['This field is required.']
        )

    def test_patch_record_works_when_service_is_empty(self):
        self.client.login(
            username='owner_with_access', password='owner_with_access'
        )
        record = self._record_for_update()

        response = self.send_patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'remarks': 'update'},
        )

        self.assertEqual(response.status_code, 200)

    def test_patch_record_update_service_when_empty_earlier(self):
        self.client.login(
            username='owner_with_access', password='owner_with_access'
        )
        record = self._record_for_update()
        service = ServiceFactory()

        response = self.send_patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={'service': service.id, 'remarks': 'update'},
        )

        record.refresh_from_db()
        self.assertEqual(record.service.id, service.id)
        self.assertEqual(response.data['service'], service.id)

    def test_patch_record_works_when_service_is_changing(self):
        self.client.login(
            username='owner_with_access', password='owner_with_access'
        )
        record = self._record_for_update()
        record.service = ServiceFactory()
        record.save()

        new_service = ServiceFactory()
        response = self.send_patch(
            reverse('api:v2:record-detail', kwargs={'pk': record.pk}),
            data={
                'service': new_service.id,
                'remarks': 'update'
            },
        )

        record.refresh_from_db()
        self.assertEqual(record.service.id, new_service.id)
        self.assertEqual(response.data['service'], new_service.id)

redpajama_set_name: RedPajamaGithub


NEW lower price for this bright, open unit, 1/2 block to the beach, with a glimpse of the ocean from the south facing balcony. New vertical blinds to let the sun in. Nicely furnished for beach fun. Sleeps 8 people, with low maintenance tile floors. Wet bar in LR. Indoor & outdoor pool, Fitness center and 2 covered parking spaces. Generates easily $17,000-$18,000 in rentals, or keep this slice of heaven all to yourself! Must honor 2019 rentals.


This wonderful large silver plated wine cooler is by the English company Mappin & Webb. The cooler is slightly tapered and has three raised but integral hoops as you would see on an old beer keg/barrel. The handles are shaped like flat bottomed upside down "U". the cover is slightly downed with round ring handles and a hole in the centre that sits around the neck of the bottle. There is a cylindrical removable canister inside the cooler.
The base is stamped "Mappin & Webb Electro Plate Britannia metal Sheffield & London 5658".
I have described this a cooler rather than an ice bucket as I think cold water rather than ice would have been put into the bucket and the canister containing the wine bottle would then have been put into the bucket. There is insufficient room to put ice between the canister and the inner wall of the bucket, unless crushed ice was used. I am aware that I might be treading on thin ice here! Anyway whatever the description it is still a magnificent & useful thing and could also be used for flowers just as well as for a bottle!


text:
KadinQuill's Gallery (6)
4Suits - Chapter 3
4suits_ch3.txt
Keywords male 694993, female 574294, fox 146850, feline 82884, rabbit 70920, vulpine 22456, hare 4819, darkness 1167, pole dancing 709, supernatural 413, alice in wonderland 156, leopard cat 34
It's sweet, just how he liked it. The fox blissfully sips away at his piping hot tea, unaware of how the hare could possibly have known how he liked his tea seeing as the fox never informed this 'Mad Hatter'. Nevertheless, he enjoys it all the same and could savor the rich texture even further if it weren't for a certain feline trying to stare a hole into the side of the poor fox's head.
The vulpine turns to the cat, eyes closed and sporting his most genuine smile. "Can I help you?" Normally, he'd be concerned about showing so much teeth, but considering the carnivorous nature of the two of them and the fact that his café host is very clearly off his rocker, he doubts he could scare anyone off. That is, unless he forgot to brush. Shoot. Did he?
"You're eyes. Where did you get them?" His smile fades and a look of confusion paints his muzzle. What kind of question is that?
"My parents?" He forces out a chuckle to try and break the awkwardness that has brewed from such an odd question. He figured he's get more questions about his oddly colored fur more than his silvery eyes. After all, how often do you see a pink furred fox roaming the land. Well, maybe it's more often that he would think, but back in his home he was the talk of the town, and nearly the town's bicycle if half of the guys had their way.
"Are there others whom your parents gave these eyes to? If so, why? What are they trying to accomplish? Why are they trying to accomplish it?! Where are they?!" As she bombards his with questions, he can feel her coming closer and closer. The hostility emanating from her is so obvious it may as well be a dense cloud attempting to suffocate the answers out of him.
"Whoa! Whoa!" He throws up his paws submissively. "Last I checked I was an only child. I think the only thing my parents wanted to accomplish was carrying on their legacy through me, and I doubt they're very happy about who I am now." He sighs as he thinks back to the moment before he had finally left his old town in the desert. Not as many teary-eyed goodbyes as he had hoped. "I'd tell you were they are, but only if you promise not to dig up their graves!" He fakes a laugh, trying and failing once again to create a more joyful mood.
All he heard was a click of her tongue before feeling her grasp his wrist as she dragged him to Joker knows where. Before he knew it, he is wiped around and his back hits a brick wall. His eyes wide open at this point as he notices that he's nose to nose with the feline and she is far from happy.
She pulls off her hood, and he finally sees the darkness that flows freely from her left eye and slowly dissipates into the air around them. "Stop playing dumb! I know you can see it! Everyone one of you freaks could, and every time you'd see me, one of you would try to strike me down! I don't know who your leader is but trust me I WILL find him and I WILL kill him." She raises a paw and he can see a massive shadow spear forming behind her. "Just like how I'm going to kill you."
Before she could launch her attack, the fox ducks off the wall and dashes toward the exit of the alleyway. He knows that she's going to attack anyway, so in one graceful motion, he flips through the air, barely dodging the spear and landing on his side. Never could stick that landing. Quickly, he gets to his feet, prepared for the next attack.
She's already formed several more spears and sends them flying with no warning. He ducks to avoid the first one then pushes off the ground and dashes to a nearby wall, kick-flipping off it and grabs the second spear from midair. Using the moment from the spear, he spins in midair and throws it into the ground. Once he lands, he launches himself toward the grounded spear and spins around it so that he can kick the next one away. He keeps the momentum going and spins around with enough force that he manages to hook a leg around the upper part of the spear and he hangs there upside down. The last spear speeds toward him, but the fox merely blows it a kiss and it explodes into a mist of darkness.
He smiles at the right-side up feline as she stares at him in shock. "What. On earth. Was that?" The fox gracefully unhooks himself from the pole and lands on his feet. He brushes himself off and tries his best to hide the growing blush. It's been a long time since he had to do something like that. "Who are you?" Her bewildered stare never fading.
"Nathaniel Kuroi." He bows politely. "Not often do I get to meet another person who can use the darkness like that!" He pants softly, small puffs of shadow escaping his maw.
"...Clover." She throws her hood back on and grasps the handle of a door, presumably back toward the Alice Café. "Pleased to meet you." She disappears inside, leaving an excited vulpine behind.
by KadinQuill
First in pool
4Suits
4 in pool next »
Yay! Violence!
male 694,993, female 574,294, fox 146,850, feline 82,884, rabbit 70,920, vulpine 22,456, hare 4,819, darkness 1,167, pole dancing 709, supernatural 413, alice in wonderland 156, leopard cat 34
Type: Writing - Document
Published: 1 year ago 07 Jul 2018 22:24 CEST
Rating: Mature
Initial: 5da657be346b27f8fb446d1842bcb0af
Full Size: 5da657be346b27f8fb446d1842bcb0af


text:
Pitt women's soccer team defeats NJIT 5-0
By Mike Wilson Aug 29, 2021, 4:42pm EDT
Share All sharing options for: Pitt women's soccer team defeats NJIT 5-0
PittsburghPanthers.com
The Pitt women's soccer team hosted NJIT at Ambrose Urbanic Field on Sunday afternoon, and the result was a dominant 5-0 victory over the visiting Highlanders.
Ellie Coffield opened up the scoring for Pitt in the 17th minute, with a one-timer off an Amanda West pass across the goal mouth. The goal was the former WPIAL star's first at Ambrose Urbanic Field and her second of the season, and it increased her point total for the year to six in four games.
.@elliecoffield1 first goal at Ambrose!
: https://t.co/liCceGvTg2
#H2P pic.twitter.com/yURO0ksKgB
— Pitt Women's Soccer (@Pitt_WSOC) August 29, 2021
The second goal came off the foot of Anna Bout after Leah Pais found her in the box with a well-placed pass. Bout then tapped a shot to the left of NJIT goalkeeper Molly Saylor and found the back of the net to give Pitt a 2-0 advantage in the 40th minute.
In the second half, Amanda West would improve Pitt's lead to 3-0 in the 56th minute, driving from midfield to the top of the box and banking a shot in off the crossbar. With her goal on Sunday, West extended her current scoring streak to four games and increased her career total to 27 goals.
Give @amanda_westt some free space,& this is what happens ⬇
#H2P pic.twitter.com/tkLrDT288h
Six minutes later, Landy Mertz would score the Panthers' fourth goal of the game after shedding a few defenders with a give and go with Sarah Schupansky and then placing a shot to the left of Saylor. The goal was the Upper St. Clair native's first of the season as well as the seventh of her collegiate career.
Krystyna Rytel would put the finishing touches on the win in the 83rd minute, when she scored her first goal of the season and the second of her career on a free kick. From well beyond the box, Rytel sent a shot over the outstretched hands of the NJIT goalkeeper, and it ricocheted off the crossbar and into the goal.
This free kick from Krystyna Rytel
#H2P pic.twitter.com/AZOEQrdOkH
The 5-0 win was Pitt's third shutout in four games, with the others coming against Tulsa and Cleveland State. It was also the team's fourth win of the 2021 season, and it improved the Panthers' record to a perfect 4-0.
With the win in the books, Pitt will shift its focus to St. Joseph's, a 0-3-1 team out of the Atlantic 10 that it will face later this week in Philadelphia. That game will kick off from Sweeney Field at 7 p.m. ET on Thursday.